HBASE-26392 Update ClassSize.BYTE_BUFFER for JDK17 (#3784)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
8e7f78cb44
commit
a5a349f289
|
@ -257,7 +257,11 @@ public class ClassSize {
|
||||||
LINKEDLIST_ENTRY = align(OBJECT + (2 * REFERENCE));
|
LINKEDLIST_ENTRY = align(OBJECT + (2 * REFERENCE));
|
||||||
|
|
||||||
//noinspection PointlessArithmeticExpression
|
//noinspection PointlessArithmeticExpression
|
||||||
BYTE_BUFFER = align(OBJECT + REFERENCE +
|
BYTE_BUFFER = JVM.getJVMSpecVersion() < 17 ?
|
||||||
|
align(OBJECT + REFERENCE +
|
||||||
|
(5 * Bytes.SIZEOF_INT) +
|
||||||
|
(3 * Bytes.SIZEOF_BOOLEAN) + Bytes.SIZEOF_LONG) + align(ARRAY) :
|
||||||
|
align(OBJECT + 2 * REFERENCE +
|
||||||
(5 * Bytes.SIZEOF_INT) +
|
(5 * Bytes.SIZEOF_INT) +
|
||||||
(3 * Bytes.SIZEOF_BOOLEAN) + Bytes.SIZEOF_LONG) + align(ARRAY);
|
(3 * Bytes.SIZEOF_BOOLEAN) + Bytes.SIZEOF_LONG) + align(ARRAY);
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,21 @@ public class JVM {
|
||||||
|
|
||||||
private static final String JVMVersion = System.getProperty("java.version");
|
private static final String JVMVersion = System.getProperty("java.version");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The raw String of java specification version.
|
||||||
|
* "1.8" for java8, "9","10"... for Java 9, 10...
|
||||||
|
*/
|
||||||
|
private static final String JVM_SPEC_VERSION_STRING =
|
||||||
|
System.getProperty("java.specification.version");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Integer represent of JVM_SPEC_VERSION, for the JVM version comparison.
|
||||||
|
* Java 8, 9, 10 ... will be noted as 8, 9 10 ...
|
||||||
|
*/
|
||||||
|
private static final int JVM_SPEC_VERSION = JVM_SPEC_VERSION_STRING.contains(".") ?
|
||||||
|
(int) (Float.parseFloat(JVM_SPEC_VERSION_STRING) * 10 % 10) :
|
||||||
|
Integer.parseInt(JVM_SPEC_VERSION_STRING);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Get the running Operating System instance
|
* Constructor. Get the running Operating System instance
|
||||||
*/
|
*/
|
||||||
|
@ -106,6 +121,10 @@ public class JVM {
|
||||||
return ibmvendor && JVMVersion.contains("1.6.0");
|
return ibmvendor && JVMVersion.contains("1.6.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getJVMSpecVersion() {
|
||||||
|
return JVM_SPEC_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the implementation of UnixOperatingSystemMXBean for Oracle jvm
|
* Load the implementation of UnixOperatingSystemMXBean for Oracle jvm
|
||||||
* and runs the desired method.
|
* and runs the desired method.
|
||||||
|
|
Loading…
Reference in New Issue