-
Notifications
You must be signed in to change notification settings - Fork 7.3k
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make reflective call to Lookup lazy on first default method invocation #3448
Comments
If you can move to JDK 14 or newer this reflective call is no longer required. I suspect we'll probably make it lazy rather than eager, but I don't see us adding a call to |
#3444 was the motivation for making it lazy. This is yet another reason! The reflection is only needed when your service interfaces have default methods (on pre-14). |
I doubt reflectively calling |
I can't reflectively invoke public API? That's pretty nonsensical on the JDKs part. But since this isn't a problem with JDK 14 any more I'm inclined to make the reflective lookup on |
Fair enough. |
@JakeWharton You can definitely access all public APIs via reflection even with strong module encapsulation. |
true :)
I had JDK 11 and warning was there. Then I moved to JDK 17 and it's gone. |
This happened, at some point. The lookup is now lazy. retrofit/retrofit/src/main/java/retrofit2/DefaultMethodSupport.java Lines 36 to 37 in e34aee6
|
After moving my project to fully support JPMS (JDK11), and retrofit has become unusable due to the following error:
It seems that retrofit deeply depends on Java's Lookup class and making its constructor visible to itself. The issue becomes apparent, when using the JPMS. A workaround for this is to add
--add-opens java.base/java.lang.invoke=retrofit2
but it would be nice if there wasn't such need to expose the base module's packages myself. Perhaps add a call toModule#addOpen(String, Module)
when initializing retrofit's class?The text was updated successfully, but these errors were encountered: