File tree Expand file tree Collapse file tree
hbase-common/src/main/java/org/apache/hadoop/hbase/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -257,7 +257,11 @@ public static boolean useUnsafeLayout() {
257257 LINKEDLIST_ENTRY = align (OBJECT + (2 * REFERENCE ));
258258
259259 //noinspection PointlessArithmeticExpression
260- BYTE_BUFFER = align (OBJECT + REFERENCE +
260+ BYTE_BUFFER = JVM .getJVMSpecVersion () < 17 ?
261+ align (OBJECT + REFERENCE +
262+ (5 * Bytes .SIZEOF_INT ) +
263+ (3 * Bytes .SIZEOF_BOOLEAN ) + Bytes .SIZEOF_LONG ) + align (ARRAY ) :
264+ align (OBJECT + 2 * REFERENCE +
261265 (5 * Bytes .SIZEOF_INT ) +
262266 (3 * Bytes .SIZEOF_BOOLEAN ) + Bytes .SIZEOF_LONG ) + align (ARRAY );
263267
Original file line number Diff line number Diff line change @@ -60,6 +60,21 @@ public class JVM {
6060
6161 private static final String JVMVersion = System .getProperty ("java.version" );
6262
63+ /**
64+ * The raw String of java specification version.
65+ * "1.8" for java8, "9","10"... for Java 9, 10...
66+ */
67+ private static final String JVM_SPEC_VERSION_STRING =
68+ System .getProperty ("java.specification.version" );
69+
70+ /**
71+ * The Integer represent of JVM_SPEC_VERSION, for the JVM version comparison.
72+ * Java 8, 9, 10 ... will be noted as 8, 9 10 ...
73+ */
74+ private static final int JVM_SPEC_VERSION = JVM_SPEC_VERSION_STRING .contains ("." ) ?
75+ (int ) (Float .parseFloat (JVM_SPEC_VERSION_STRING ) * 10 % 10 ) :
76+ Integer .parseInt (JVM_SPEC_VERSION_STRING );
77+
6378 /**
6479 * Constructor. Get the running Operating System instance
6580 */
@@ -106,6 +121,10 @@ public static boolean isGZIPOutputStreamFinishBroken() {
106121 return ibmvendor && JVMVersion .contains ("1.6.0" );
107122 }
108123
124+ public static int getJVMSpecVersion () {
125+ return JVM_SPEC_VERSION ;
126+ }
127+
109128 /**
110129 * Load the implementation of UnixOperatingSystemMXBean for Oracle jvm
111130 * and runs the desired method.
You can’t perform that action at this time.
0 commit comments