New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java9 Support, remove use of unsupported api:s #556
Comments
Didn't find any easy solution, one solution to support different jdk provider and 7-9 https://sourceforge.net/p/tuer/code/HEAD/tree/pre_beta/src/main/java/engine/misc/DeallocationHelper.java |
Found a possible solution at pethers@60916dd , tested with JDK8, JDK9_b121 require jvm option for JDK9 |
Thanks @pethers |
No hurry, don't expect to run JDK9 any time soon. Just want to make sure all blockers are resolved before the java 9 release. Probably a lots of other people having the same issues, so maybe a better solution shows up later on. |
I have made some research and jdk state has changed since last year. There is JDK-4724038 which is not yet resolved, but JDK-8171377 is resolved and available in JDK9 build 150. So when java 9 is detected, we could use some code like this in RrdNioBackend.unmapFile(): final Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
final Field theUnsafeField = unsafeClass.getDeclaredField("theUnsafe");
theUnsafeField.setAccessible(true);
final Object theUnsafe = theUnsafeField.get(null);
final Method invokeCleanerMethod = unsafeClass.getMethod("invokeCleaner", ByteBuffer.class);
invokeCleanerMethod.invoke(theUnsafe, byteBuffer); (This may fail on non-Hotspot/OpenJDK JVMs and the class or method may not be available.) The trick is that the sun.misc.Unsafe is in the critical internal API list proposed to remain accessible in JDK 9, whereas sun.misc.Cleaner and sun.nio.ch.DirectBuffer are unfortunately not in that list. That's the cause for the new invokeCleaner method in sun.misc.Unsafe added in JDK 9. |
Looks good, happy to test if needed ? |
Yes you can. It would be great. |
Done some test with master...pethers:master , worked well with JDK8 and JDK9 Build 155 . Tested with https://www.hack23.com/jenkins/view/Future/job/Citizen-Intelligence-Agency-System-Test-jdk9/ and https://www.hack23.com/jenkins/job/Citizen-Intelligence-Agency-System-Test/ . |
I clicked on "create pull request" in the comparison. |
still an issue for me in version 1.69.0 : with jdk 9 in ubuntu 16.04 9-internal+0-2016-04-14-195246.buildd.src |
@lepirlouit |
Hello, I use the jRobin1.5.9.1. I see the exception with java9 runtime. The solutions i.e. adding below additions to jvm arguments does not work . Could you suggested what's the latest fix for this problem? Exception seen: thanks |
@hemmanj |
jdeps -jdkinternals javamelody-core-1.59.0.jar
javamelody-core-1.59.0.jar -> JDK removed internal API
javamelody-core-1.59.0.jar -> java.base
net.bull.javamelody.RrdNioBackend -> sun.misc.Cleaner JDK internal API (JDK removed internal API)
net.bull.javamelody.RrdNioBackend -> sun.nio.ch.DirectBuffer JDK internal API (java.base)
Tested with jdk9-b121,
[exec] 2016-06-07 22:09:00,994 [main] WARN n.b.javamelody - exception while collecting data: java.lang.IllegalAccessError: class net.bull.javamelody.RrdNioBackend (in unnamed module @0x65d6b83b) cannot access class sun.nio.ch.DirectBuffer (in module java.base) because module java.base does not export sun.nio.ch to unnamed module @0x65d6b83b
[exec] java.lang.IllegalAccessError: class net.bull.javamelody.RrdNioBackend (in unnamed module @0x65d6b83b) cannot access class sun.nio.ch.DirectBuffer (in module java.base) because module java.base does not export sun.nio.ch to unnamed module @0x65d6b83b
[exec] at net.bull.javamelody.RrdNioBackend.unmapFile(RrdNioBackend.java:101)
[exec] at net.bull.javamelody.RrdNioBackend.close(RrdNioBackend.java:167)
[exec] at org.jrobin.core.RrdDb.close(RrdDb.java:450)
[exec] at org.jrobin.core.RrdDbPool.release(RrdDbPool.java:192)
[exec] at net.bull.javamelody.JRobin.addValue(JRobin.java:354)
[exec] at net.bull.javamelody.Collector.collectJRobinValues(Collector.java:511)
Can force export of sun.nio.ch.DirectBuffer with arg "-XaddExports:java.base/sun.nio.ch=ALL-UNNAMED"
According to https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool , sun.misc.Cleaner can be replaced with java.lang.ref.PhantomReference @SInCE 1.2 .
Last exception
2016-06-07 22:25:55,403 [main] WARN n.b.javamelody - exception while collecting data: java.lang.NoSuchMethodError: sun.nio.ch.DirectBuffer.cleaner()Lsun/misc/Cleaner;
[exec] java.lang.NoSuchMethodError: sun.nio.ch.DirectBuffer.cleaner()Lsun/misc/Cleaner;
[exec] at net.bull.javamelody.RrdNioBackend.unmapFile(RrdNioBackend.java:102)
[exec] at net.bull.javamelody.RrdNioBackend.close(RrdNioBackend.java:167)
[exec] at org.jrobin.core.RrdDb.close(RrdDb.java:450)
[exec] at org.jrobin.core.RrdDbPool.release(RrdDbPool.java:192)
[exec] at net.bull.javamelody.JRobin.addValue(JRobin.java:354)
[exec] at net.bull.javamelody.Collector.collectJRobinValues(Collector.java:511)
Will try to provide a pull request later this week.
The text was updated successfully, but these errors were encountered: