I would like to know what is the usage of sun.misc.unsafe.arrayIndexScale, in the javadoc
it is said that:
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.
This method returns an int
, but I am not sure what the value means.
The method gives you Java object memory layout information.
This is used to determine the amount of memory that the given array is occupying. Scale Factor is a term that represents how much a given quantity, in this case memory, is being multiplied by to represent the total. You should not use the method that you are trying to use; it's UNSAFE.
However, there are safer versions that you can use:
staticFieldBase
or staticFieldOffset
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With