Skip to content
Commits on Source (2)
openhft-chronicle-core (2.17.5-v1.1.8-1) unstable; urgency=medium
* Revert a previous erroneous upload of 2.17.5.
* Build for Java 9, also fixing compatibility with Java 11.
Closes: #917736.
-- Andrej Shadura <andrewsh@debian.org> Wed, 27 Feb 2019 20:55:13 +0100
openhft-chronicle-core (2.17.5-1) unstable; urgency=medium
* New upstream version 2.17.5.
* Use java11 profile when building.
* Make sure the compiler args are used, set fork=true.
* Set source and target to Java 11
* Java 11 drops defineClass from sun.misc.Unsafe (Closes: #917736).
-- Andrej Shadura <andrewsh@debian.org> Wed, 27 Feb 2019 17:10:30 +0100
openhft-chronicle-core (1.16.25-1) experimental; urgency=medium
* Team upload to experimental.
* New upstream version 1.16.25
-- tony mancill <tmancill@debian.org> Sat, 15 Sep 2018 21:47:41 -0700
openhft-chronicle-core (1.16.24-1) experimental; urgency=medium
* Team upload to experimental.
* New upstream version 1.16.24
* Set source and target to Java 8
* Build-dep on openhft-affinity 3.1.7.
* Bump Standards-Version to 4.2.1
* Update Vcs URLs to point to Salsa
* Set source encoding to UTF-8 in debian/maven.properties
* Enable tests
-- tony mancill <tmancill@debian.org> Wed, 12 Sep 2018 20:29:36 -0700
openhft-chronicle-core (1.1.8-1) unstable; urgency=medium openhft-chronicle-core (1.1.8-1) unstable; urgency=medium
* Initial release (Closes: #832906) * Initial release (Closes: #832906)
......
From: Andrej Shadura <andrewsh@debian.org>
Date: Wed, 27 Feb 2019 17:03:02 +0100
Subject: Fixes the compatibility with Java 11
--- a/src/main/java/net/openhft/chronicle/core/ClassLoading.java
+++ b/src/main/java/net/openhft/chronicle/core/ClassLoading.java
@@ -41,6 +41,10 @@
* @return the class loaded.
*/
private static Class defineClass(ClassLoader classLoader, String className, byte[] bytes) {
- return UnsafeMemory.UNSAFE.defineClass(className, bytes, 0, bytes.length, classLoader, null);
+ try {
+ return (Class) UnsafeMemory.defineClassMethodHandle.bindTo(classLoader).invokeWithArguments(className, bytes, 0, bytes.length);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
}
}
--- a/src/main/java/net/openhft/chronicle/core/UnsafeMemory.java
+++ b/src/main/java/net/openhft/chronicle/core/UnsafeMemory.java
@@ -18,12 +18,16 @@
import net.openhft.chronicle.core.annotation.ForceInline;
import sun.misc.Unsafe;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
import java.lang.reflect.Field;
import java.util.concurrent.atomic.AtomicLong;
public class UnsafeMemory implements Memory {
static Unsafe UNSAFE;
+ static MethodHandle defineClassMethodHandle;
private final AtomicLong nativeMemoryUsed = new AtomicLong();
public static Memory create() {
@@ -34,6 +38,14 @@
} catch (IllegalAccessException | IllegalArgumentException e) {
throw new AssertionError(e);
}
+ try {
+ MethodHandles.Lookup baseLookup = MethodHandles.lookup();
+ MethodType defineClassMethodType = MethodType.methodType(Class.class, new Class[]{String.class, byte[].class, int.class, int.class});
+ MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(ClassLoader.class, baseLookup);
+ defineClassMethodHandle = lookup.findVirtual(ClassLoader.class, "defineClass", defineClassMethodType);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
}
return new UnsafeMemory();
}
--- a/pom.xml
+++ b/pom.xml
@@ -105,8 +105,12 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-Xlint:deprecation</compilerArgument>
- <source>1.8</source>
- <target>1.8</target>
+ <source>1.9</source>
+ <target>1.9</target>
+ <compilerArgs>
+ <arg>--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED</arg>
+ <arg>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</arg>
+ </compilerArgs>
</configuration>
</plugin>
<!--
--- a/src/main/java/net/openhft/chronicle/core/io/IOTools.java
+++ b/src/main/java/net/openhft/chronicle/core/io/IOTools.java
@@ -16,8 +16,6 @@
package net.openhft.chronicle.core.io;
-import sun.reflect.Reflection;
-
import java.io.*;
/**
@@ -29,7 +27,8 @@ public enum IOTools {
public static byte[] readFile(String name) throws IOException {
ClassLoader classLoader;
try {
- classLoader = Reflection.getCallerClass().getClassLoader();
+ StackWalker instance = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
+ classLoader = instance.getCallerClass().getClassLoader();
} catch (Throwable e) {
classLoader = Thread.currentThread().getContextClassLoader();
}
java11-compatiblitily.patch