Retrieves the array index scale for the array Class given. The index scale is the value used to determine the offset of a particular element in the array given the array's base offset and an index. The following code snippet illustrates the usage.
int base = unsafe.arrayBaseOffset(int[].class); int scale = unsafe.arrayIndexScale(int[].class); int elementIdx = 1; int[] array = { 0, 1, 2 }; long offsetForIdx = base + (elementIdx * scale);
The Class passed MUST me any array type, such that the method {@link Class#isArray()} returns true
. For example,int[].class
.
|
|