java - arrayIndexScale 返回的值指的是什么?

标签 java

我想知道sun.misc.unsafe.arrayIndexScale的用法,在javadoc中是这样说的:

Report the scale factor for addressing elements in the storage allocation of a given array class. However, arrays of "narrow" types will generally not work properly with accessors like getByte(java.lang.Object,int), so the scale factor for such classes is reported as zero.

此方法返回一个 int,但我不确定该值的含义。

最佳答案

该方法为您提供 Java 对象内存布局信息。

这用于确定给定数组占用的内存量。比例因子是一个术语,表示给定数量(在本例中为内存)乘以多少以表示总数。 您不应该使用您正在尝试使用的方法;这是不安全的

但是,您可以使用更安全的版本: staticFieldBasestaticFieldOffset

关于java - arrayIndexScale 返回的值指的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29898941/

相关文章:

java - AppEngine(Java)中cron作业的复杂时间表

java - 将 html 页面设置为 servlet 响应

java - REST API ArrayList @DELETE

java - 如何设置文件输入流的路径

java - 素数 - 困境

java - Tomcat 8.5 识别新内容的时间过长

java - 无法使用 Java 更新 mySQL 数据库中的行,没有错误消息

java - 在方法之间共享原始数据?

java - 尝试显示消息框时,NetBeans IDE 6.9.1 中的 Glassfish 服务器停止工作

java - 为什么 [a-z][A-Z] 给出的结果与 [ą-ž][Ą-Ž] 不同?