feign: Illegal reflective access by feign.DefaultMethodHandler in Java 11

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

About this issue

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

Commits related to this issue

Most upvoted comments

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).

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.