question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
Tomas-Krauscommented, Sep 21, 2018

@bravehorsie Commented 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 notifications@github.com 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 .

0reactions
bourgeslcommented, Mar 31, 2021

Thanks. My fat jar already had META-INF/versions folder but ‘Multi-Release: true’ was missing in the MANIFEST.MF ! I will get rid of my JDK16 fix as it works now like a charm !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proper fix for Java 10 complaining about illegal reflection ...
Apparently this is not the correct fix. WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.
Read more >
Java 9: Illegal reflective access by com.sun.xml.bind.v2 ...
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.
Read more >
Java 9 Illegal Reflective Access Warning - Baeldung
In this tutorial, we'll inspect the relationship between the module system and reflection. 2. Modular System and Reflection.
Read more >
WARNING: Illegal reflective access by com.sun.xml.bind.v2 ...
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector on JDK 9. Status: Assignee: Priority: Resolution:.
Read more >
Illegal reflective access with createFromXmlResource()
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/C:/blah.jar) to method java.lang.ClassLoader.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found