[Git][java-team/openhft-chronicle-core][master] 2 commits: Java 11 drops defineClass from sun.misc.Unsafe

Andrej Shadura gitlab at salsa.debian.org
Wed Feb 27 22:21:55 GMT 2019


Andrej Shadura pushed to branch master at Debian Java Maintainers / openhft-chronicle-core


Commits:
bf04b635 by Andrej Shadura at 2019-02-27T20:16:44Z
Java 11 drops defineClass from sun.misc.Unsafe

Closes: #917736

- - - - -
d9b83d44 by Andrej Shadura at 2019-02-27T20:48:56Z
Update the changelog

- - - - -


3 changed files:

- debian/changelog
- + debian/patches/java11-compatiblitily.patch
- + debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,41 @@
+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 at 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 at 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 at 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 at debian.org>  Wed, 12 Sep 2018 20:29:36 -0700
+
 openhft-chronicle-core (1.1.8-1) unstable; urgency=medium
 
   * Initial release (Closes: #832906)


=====================================
debian/patches/java11-compatiblitily.patch
=====================================
@@ -0,0 +1,90 @@
+From: Andrej Shadura <andrewsh at 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();
+         }


=====================================
debian/patches/series
=====================================
@@ -0,0 +1 @@
+java11-compatiblitily.patch



View it on GitLab: https://salsa.debian.org/java-team/openhft-chronicle-core/compare/2597ae734b74b481fedaa4f9a91585aa23f0d724...d9b83d4425715094d2f3b92b8f2a4467c2b6267e

-- 
View it on GitLab: https://salsa.debian.org/java-team/openhft-chronicle-core/compare/2597ae734b74b481fedaa4f9a91585aa23f0d724...d9b83d4425715094d2f3b92b8f2a4467c2b6267e
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20190227/fc5eb981/attachment.html>


More information about the pkg-java-commits mailing list