What is the value returned by arrayIndexScale?

I would like to know what the use of sun.misc.unsafe.arrayIndexScale is, javadoc says that:

Report the scale factor for addressing items in the storage distribution for this array class. However, arrays of narrow types usually do not work properly with accessories such as getByte(java.lang.Object,int) , so the scale factor for such classes is reported as zero.

This method returns an int , but I'm not sure what the value means.

+5
source share
1 answer

This method gives you information about the memory location of a Java object.

Used to determine the amount of memory occupied by this array. A scale factor is a term that represents how much a given amount, in this case, memory, is multiplied by the total. You cannot use the method that you are trying to use; this is unsafe .

However, there are safer versions that you can use: staticFieldBase or staticFieldOffset .

+2
source

All Articles