我想知道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 对象内存布局信息。
这用于确定给定数组占用的内存量。比例因子是一个术语,表示给定数量(在本例中为内存)乘以多少以表示总数。 您不应该使用您正在尝试使用的方法;这是不安全的。
但是,您可以使用更安全的版本:
staticFieldBase
或 staticFieldOffset
。
关于java - arrayIndexScale 返回的值指的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29898941/