JDK-8170042 : AccessorInjector optimization in JAXB needs to be re-examined
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxb
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-11-19
  • Updated: 2017-02-10
  • Resolved: 2017-01-27
Related Reports
Relates :  
Description
Jigsaw restricts setAccessible across module boundaries.

We are seeing the following stack trace.

     [java]   [carbgen] java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @3b5fad2d
     [java]   [carbgen]         at java.base/jdk.internal.reflect.Reflection.throwInaccessibleObjectException(Reflection.java:424)
     [java]   [carbgen]         at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:198)
     [java]   [carbgen]         at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:192)
     [java]   [carbgen]         at java.base/java.lang.reflect.Method.setAccessible(Method.java:186)
     [java]   [carbgen]         at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.getMethod(Injector.java:184)

This is the standalone version (the JDK version is in a different package). This is solved for the JDK version but it's not in the standalone version yet.

Comments
this is resolved in standalone for about a week already
27-01-2017

Andriy Zhdanov has a fix for this issue. Once it comes to JDK 9 then we can undo the re-enable the optimization in com/sun/xml/internal/bind/v2/runtime/reflect/opt/AccessorInjector.java.
20-12-2016

This issue duplicates with the standalone version of the JAXB implementation when running on builds of jigsaw/jake. The issue is the AccessorInjector optimization is hacking into ClassLoader::defineClass. The JAXB code has changed in jigsaw/jake to not attempt this optimization and so jake builds do not hit this issue. The JAXB maintainers are aware of the issue, the main AIs are to see if the optimization is still beneficial and if so, to change to use Unsafe::defineClass. One everything has settled then the standalone and implementations in the JDK should be sync'ed up.
20-11-2016