-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Java 9 (JDK-9) support for guice #1085
Comments
@felixblaschke This is particularly the fault of cglib. Google "Java 9 cglib" to find relevant discussions. |
@brettwooldridge are you referring to this issue? Linking to the page(s) you think are relevant is much more helpful than suggesting a Google search. |
I actually wasn't referring to any one specific page. But as long as you're linking to one, I'll throw this abridged version of War and Peace into the mix. |
cglib 3.2.5 seems to fix this issue. But Guice seems to repackage cglib. Therefore it seems I am not able to just include cglib 3.2.5? But I built my own version of guice using cglib 3.2.5 and now I can launch my application with Java 9-ea+162. You should consider creating a new version of Guice with cglib 3.2.5. |
yes. please release new version of guice |
I'm also suffering from this problem. Releasing a new version or unbundling cglib would be nice. |
The first RC for Java 9 has been published: http://mail.openjdk.java.net/pipermail/jdk9-dev/2017-August/005940.html So, it seems like a good time to fix this (bumping the cglib version seems like a simple fix too). |
The java.lang package is open for so-call deep reflection by default so this allows existing hacks to continue to work for a bit longer. In the future then this will cause so Guice and/or cglib should look at the new Lookup.defineClass, it's the support way for libraries to inject classes. |
Java 9 was released a few weeks ago, it's high time to update Guice. |
What is the status of this issue? Is someone from contributors aware of this? |
@DigitalSmile The whole project seems to be abandoned. Despite almost everyone uses Spring, previously I at least knew that there is a pure DI framework. And now I know of no alternatives to Spring :( |
FYI: I have a branch in which I made everything work with JDK 9 - by unbundling and upgrading the dependencies. I'm using this in production on JDK9 for over a month now without a problem. The branch has the deployment settings changed to work with my local Artefactory, so if you want to use this you have to adjust the settings. |
Guice is definitely not abandoned! But it's currently maintained by volunteers, and pulling everything together for a new Open Source release just hasn't been prioritized. This will get fixed, but I can't offer any sort of ETA at the moment :( |
@dimo414 thanks for the insight and heads up. I can understand, it is an Open Source code and is supported by community, still it is stated very clearly, that Google has a "patronage" over this project... For months and months there are no activities (or at least all other community cannot see this). Thanks for all your effort guys! The lib is awesome. |
FYI we're trying to get the OS build moving again. Stay posted! |
@dimo414 are you going to fully support Jigsaw or it's just a fix for running with JDK9? |
@DigitalSmile I'm not in a position to commit to supporting anything :) but we certainly want Guice to work wherever possible, and once the OS build is fixed it will be easier to address these issues. |
We get a different exception when running Guice 4.1.0 with Java 9: error.log This The line in the ASM source that causes the problem is that one here which explicitly makes Java versions greater than 8 fail. In ASM version 6.0 that line is definitely compatible with Java 9. ASM 6.0 brings full support for Java 9 class files. Read the release announcement here:
@dimo414 Please update to ASM 6.0 (by replacing the jar). @rototor You may want to upgrade to ASM 6.0 in your branch you mentioned above. |
@dimo414 there are at least 3 forks I've seen that fixes it to the point where guice compiles and runs on jdk9. Although there are tools like https://jitpack.io/ that allows you to basically build these forks and use them as maven dependency, I believe there are companies that are not exactly fine with that. |
@sameb @lukesandberg can you please take a look at the referenced PRs 🐱 ? It is in fact a blocker now and soon a whole year passed since opening this issue. |
I have to agree this is a royal nuisance in the buttocks. Guice + JDK9 is not really usable for us due to this issue and JDK9 has been in GA for almost 4 months now. It almost looks as if this project is orphaned. |
I'd have to agree - it looks as if the public version of Guice has been left to rot. 😿 |
We're working right now to get our changes since e7bef34 merged in. Some of those changes get us closer to Java 9 support, and fix some of the issues in the PRs. After that, let's see what we have left to do. |
I have to agree with @anthraxx. @ronshapiro / @netdpb : What is missing? Is there anything we could help you with? Additional testing? |
With this update, will guice be compatible with jdk10 too? It is waiting behind the corner. |
To support Java 10 guice has to upgrade to ASM 6.1 when it is released. Right now it is in beta2: https://gitlab.ow2.org/asm/asm/tags |
We're working on the 4.2 release, hopefully for this week. |
guice 4.2 is released w/ java9 support. |
Thanks a lot for the work involved and taking care of this. |
Thanks a lot for the new release. Missing bindings are now beautifully reported in the logs. For the record though, we are still getting illegal access warnings:
|
It use to useful to test Guice with |
Referenced this issue in |
ASM 6.1 with Java 10 support has been released: |
ASM 6.1.1 has been released, needed for Java 10 support. |
ASM 6.2 released with better JDK 10 support and even with JDK 11 support already! |
asm 6.2.1 released. |
This looks like it has made a come back in JRE 11? Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to module com.google.guice
|
The InaccessibleObjectException in GerMarc's comment is because Guice is in a named module and it trying to hack the protected ClassLoader.defineClass method to call it from the wrong context. It can be worked around, on a temporary basis, with |
Naw this was from a push up from JRE10, so it was working fine in JPMS, I think ALL-MODULES got removed because as you pointed out exposing directly to the google guice package does get around it but using ALL-MODULES and this still comes up... Doing the module path exclusion tho makes a lot more errors later on I think there is a significant change between 10 and 11 that is breaking the injection library with regards to the exposures... |
There are no changes in this area in JDK 11, the set of packages that are opened for illegal access to code on the class path is the same as JDK 9 and JDK 10. This doesn't help Guice in the example because it is deployed as a named module, not the class path (unnamed module). The right thing is course to fix Guice to use Lookup.defineClass. |
Hmmm, It doesn't make sense then. Setting it to --add-opens java.base/java.lang=com.google.guice,javassist does work with it specified explicitely, (Hence ALL-MODULES removed theory). But what you're saying doesn't make sense with what is happening? Adding in the program parameter -Dcom.google.inject.internal.cglib.$experimental_asm7=true does assist somewhat but no AOP is available. |
InaccessibleObjectException is because Guice is in a named module, you'll see exactly the same exception with JDK 9, 10 and 11. If Guice is on the class path then the hack will work although you should see an "Illegal reflective access" warning to point out that it will break once the java.base module is fully encapsulated. |
Thanks Alan, indeed it was cglib in guice causing, I can run with the opens exposed, and the parameter configred. |
google/guice#1085 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=184283324
google/guice#1085 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=184283324
I am evaluating my projects with a pre-release Java 9 SDK. It's using recent guice that fails to inject the dependencies. Guice is trying to alter some classes in
java.base
module viasetAccessible(...)
Reflection call. Many other DI frameworks suffer from the same issue.Are you currently working on Java 9 support for guice?
I used
Java(TM) SE Runtime Environment (build 9-ea+159)
and guice1.4.1
. Build target is Java1.8
.Here is the stack trace that occured when DI-ing:
I can surpass that issue using the VM args
--add-opens java.base/java.lang=ALL-UNNAMED
The text was updated successfully, but these errors were encountered: