Use Buffer.address offset detection via shared library when under Java 9
@@ -2577,9 +2577,21 @@ abstract class MemUtil {
//#ifdef __HAS_NIO__
private static long findBufferAddress() {
+ String javaVersion = System.getProperty("java.version");
+ if ("9".equals(javaVersion) || "1.9".equals(javaVersion))
+ return findBufferAddressJDK9(null);
+ else
+ return findBufferAddressJDK1();
+ }
+ private static long findBufferAddressJDK1() {
try {
return UNSAFE.objectFieldOffset(getDeclaredField(Buffer.class, "address")); //$NON-NLS-1$
} catch (Exception e) {
+ /* Still try with shared library via address offset testing */
+ return findBufferAddressJDK9(e);
+ }
+ }
+ private static long findBufferAddressJDK9(Exception e) {
/* Maybe because of JDK9 AwkwardStrongEncapsulation. */
/* Try detecting the address from a known value. */
try {
@@ -2599,7 +2611,6 @@ abstract class MemUtil {
}
throw new UnsupportedOperationException("Could not detect ByteBuffer.address offset", e);
}
- }
//#endif
private static long checkMatrix4f() throws NoSuchFieldException, SecurityException {
