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.

Illegal reflective access by feign.DefaultMethodHandler in Java 11

See original GitHub issue

Similar to #393

This can be reproduced on Java 11 (probably also 9 and 10) with the Github example after renaming the package to notfeign.example.github (or anything that isn’t under feign.*). Can be compiled with Java 8 or 11 (the compiler doesn’t complain either way).

I reproduced on Zulu and Corretto 11.0.2 (all OpenJDK 11 implementations should behave the same):

$ java -version
openjdk version "11.0.2" 2019-01-15 LTS
OpenJDK Runtime Environment Zulu11.29+3-CA (build 11.0.2+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.29+3-CA (build 11.0.2+7-LTS, mixed mode)

$ java -version
openjdk version "11.0.2" 2019-01-15 LTS
OpenJDK Runtime Environment Corretto-11.0.2.9.1 (build 11.0.2+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.2.9.1 (build 11.0.2+9-LTS, mixed mode)
$ java -jar target/feign-example-github-10.2.1-SNAPSHOT.jar
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by feign.DefaultMethodHandler (file:/Users/gavin/test/feign/example-github/target/feign-example-github-10.2.1-SNAPSHOT.jar) to field java.lang.invoke.MethodHandles$Lookup.IMPL_LOOKUP
WARNING: Please consider reporting this to the maintainers of feign.DefaultMethodHandler
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
Let's fetch and print a list of the contributors to this org.
[GitHub#repos] ---> GET https://api.github.com/users/openfeign/repos?sort=full_name HTTP/1.1
[GitHub#repos] <--- HTTP/1.1 200 OK (554ms)
...

Note that using the --illegal-access=warn JVM option just changes the warning to just the single line calling out feign.DefaultMethodHandler.

It seems like fixing this while maintaining compatibility for older Java versions will not be fun. Refs:

https://blog.jooq.org/2018/03/28/correct-reflective-access-to-interface-default-methods-in-java-8-9-10/

https://mydailyjava.blogspot.com/2018/04/jdk-11-and-proxies-in-world-past.html

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:20 (13 by maintainers)

github_iconTop GitHub Comments

9reactions
krzykcommented, Feb 28, 2021

Just a note, wiht JDK 16 release, that will be in March this won’t be a warning but an error (so it will break the app, unless one adds a workaround).

2reactions
dpoddercommented, Apr 5, 2021

Another note, JEP 403 was announced recently as a candidate. Whenever it lands (which might even be JDK 17 at this point), --illegal-access=deny will be the default and all attempts to relax it will be ignored.

--add-opens should still be supported, at least for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is an illegal reflective access? - java - Stack Overflow
Apart from an understanding of the accesses amongst modules and their respective packages. I believe the crux of it lies in the Module ......
Read more >
OpenFeign/feign - Gitter
I'm trying to convert my spring boot project from java 8 to java 11, but I get this WARNING: WARNING: An illegal reflective...
Read more >
An illegal reflective access operation has occurred when ...
An illegal reflective access operation has occurred when using Java 11 with ForgeRock products. Last updated Aug 18, 2022.
Read more >
Java 9 Illegal Reflective Access Warning - Baeldung
Before Java 9, the Java Reflection API has a superpower: It could gain access to the non-public class members without limitation.
Read more >
Guide to Java Versions and Features - DZone
Java 8, Java 11, Java 13 — what's the difference? ... build tools print out "reflective access"-warnings when building Java projects, ...
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