jaxb-v2 icon indicating copy to clipboard operation
jaxb-v2 copied to clipboard

Java 9: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector

Open plutext opened this issue 7 years ago • 5 comments

With Java 9 or 10, using

            <dependency>
                <groupId>org.glassfish.jaxb</groupId>
                <artifactId>jaxb-runtime</artifactId>
                <version>2.3.0</version>
            </dependency>

results in:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector 
(file: repository/org/glassfish/jaxb/jaxb-runtime/2.3.0/jaxb-runtime-2.3.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

plutext avatar May 06 '18 03:05 plutext

Tracker for a similar question on Stackoverflow => Q50237516

namannigam-zz avatar May 09 '18 04:05 namannigam-zz

jaxb-ri runtime uses ClassLoader#defineClass / Unsafe#defineClass to do some bytecode modification in runtime to optimize performance. ClassLoader#defineClass is tried first which causes the warning.

This legacy optimization is removed completely in jaxb-ri master (after 2.3.0, not released yet).

To disable this optimization for 2.3.0, set system property com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize.

Roman

On Wed, May 9, 2018 at 6:57 AM, Naman Nigam [email protected] wrote:

Tracker for a similar question on Stackoverflow => Q50237516 https://stackoverflow.com/questions/50237516/proper-fix-for-java-10-complaining-about-illegal-reflection-access-by-jaxb-impl

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/javaee/jaxb-v2/issues/1197#issuecomment-387620115, or mute the thread https://github.com/notifications/unsubscribe-auth/AI8ZttSIFtRovJJhToXUxJrtfXDj2AGmks5twndJgaJpZM4Tz4Of .

bravehorsie avatar May 09 '18 10:05 bravehorsie

Hi Roman,

When I try to run with Java 9 I have the following behavior:

java -XX:+IgnoreUnrecognizedVMOptions --add-modules java.activation -cp ":./otherJars/" com.package.Main "$@"

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/.../jaxb-impl.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

And when I used noOptimize I still have some messages:

java -XX:+IgnoreUnrecognizedVMOptions -Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true --add-modules java.activation -cp ":./otherJars/" com.package.Main "$@"

May 18, 2018 12:18:52 PM com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector INFO: The optimized code generation is disabled

Do you know how to escape these messages?

The current intent for Oracle is to remove the java.se.ee modules starting with a future release which apparently is Java 11, this means we will not be able to use anymore JAXB(javax.xml.bind module).

How I can be procced further I need to change the library completely already now(find a replacement for JAXB) in order to be compatible with Java 11+ or use JAXB for Java 9 and 10 and look in the future for Java 11 solution, keep in mind java 11 will be released soon(around the end of this year). https://jaxenter.com/jdk-11-java-ee-modules-140674.html

Library used: FastInfoset-1.2.13.jar istack-commons-runtime-3.0.5.jar stax-ex-1.7.8.jar txw2-2.3.0.jar jaxb-api-2.3.0.jar jaxb-core-2.3.0.jar jaxb-runtime-2.3.0.jar

Corneliu,

corneliuc avatar May 18 '18 10:05 corneliuc

Hi Corneliu,

as I posted here: https://stackoverflow.com/questions/50237516/proper-fix-for-java-10-complaining-about-illegal-reflection-access-by-jaxb-impl Runtime code optimizaton is removed in master branch and will ship with next release. Updating to new version will remove both messages. and .noOptimize flag. Next version will be usable with Java 11, which has excluded java.xml.bind and java.xml.ws modules.

Roman

On Fri, May 18, 2018 at 12:02 PM, corneliuc [email protected] wrote:

Hi Roman,

When I try to run with Java 9 I have the following behavior:

java -XX:+IgnoreUnrecognizedVMOptions --add-modules java.activation -cp " :./otherJars/" com.package.Main "$@"

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/.../jaxb-impl.jar) to method java.lang.ClassLoader. defineClass(java.lang.String,byte[],int,int) WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

And when I used noOptimize I still have some messages:

java -XX:+IgnoreUnrecognizedVMOptions -Dcom.sun.xml.bind.v2. bytecode.ClassTailor.noOptimize=true --add-modules java.activation -cp " :./otherJars/" com.package.Main "$@"

May 18, 2018 12:18:52 PM com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector

INFO: The optimized code generation is disabled

Do you know how to escape these messages?

The current intent for Oracle is to remove the java.se.ee modules starting with a future release which apparently is Java 11, this means we will not be able to use anymore JAXB(javax.xml.bind module).

How I can be procced further I need to change the library completely already now(find a replacement for JAXB) in order to be compatible with Java 11+ or use JAXB for Java 9 and 10 and look in the future for Java 11 solution, keep in mind java 11 will be released soon(around the end of this year). https://jaxenter.com/jdk-11-java-ee-modules-140674.html

Library used: FastInfoset-1.2.13.jar istack-commons-runtime-3.0.5.jar stax-ex-1.7.8.jar txw2-2.3.0.jar jaxb-api-2.3.0.jar jaxb-core-2.3.0.jar jaxb-runtime-2.3.0.jar

Corneliu,

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/javaee/jaxb-v2/issues/1197#issuecomment-390159664, or mute the thread https://github.com/notifications/unsubscribe-auth/AI8Ztjdb1wdHQfCboWh5PZS4l39Ty_Unks5tzpxCgaJpZM4Tz4Of .

bravehorsie avatar May 18 '18 12:05 bravehorsie

When do we have the next release 2.4 available?

abdulmuqsith avatar Aug 20 '18 16:08 abdulmuqsith