All Java 8 classes opened in 2021-13 fail with Java 9 related error, but perhaps caused by Java 16 [message #1839391] |
Fri, 19 March 2021 14:20  |
Eclipse User |
|
|
|
I've been using 2020-12 since its release with many Java 8 projects. I've been running it with Java 15, but the projects are using the Java 8 JDK. This has been working fine.
I just started setting up 2021-03 today. I set it to run with Java 16. I exported my preferences from the 2020-12 workspace and imported that into the new 2021-03 workspace. I installed all the plugins I normally use.
I then imported all of the projects I need from my git repositories.
When the dust settled, I saw that any attempt to open a Java class failed with the same error:
Quote:java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @18cf5c52
I'm also seeing a slew of dialogs titled "Multiple problems have occurred", saying "Errors occurred during the build", all repeating that same error message. It got to the point that this dialog would come up as fast as I could dismiss it, as projects seemed like they were in a build loop.
The other oddity is that most of the Java projects had a single compile error, saying that "The project cannot be built until its prerequisite xxxx is built. Cleaning and building all projects is recommended". All of them report the same project name as needing to be built. The even stranger part is that there doesn't appear to be any problem with that project. It has no errors.
At that point, I exited Eclipse. I changed the eclipse.ini file to run it with Java 15. I started it back up. Everything compiled fine. I'm going to move forward with Java 15 for now.
|
|
|
|
|
|
|
|
|
Re: All Java 8 classes opened in 2021-13 fail with Java 9 related error, but perhaps caused by Java [message #1842410 is a reply to message #1839419] |
Thu, 17 June 2021 17:35  |
Eclipse User |
|
|
|
Java 16 changed the default for the restricted internal APIs. They are still there but java doesn't allow the access without explicit "opens" for the modules.
That's what your original error message is referencing: 'java.base does not "opens java.lang"'
I stumbled across the same problem with I think RC1 of eclipse 2021-06 that came bundled with the jdk 16. Don't know if it's fixed for the release, but I simply went back to jdk 11 as runtime environment. It doesn't matter if you want to compile your sources with a later jdk -- the eclipse platform itself can easily run with a different version.
If you want to fix the "opens"-problem here's a pattern for some kinds of startup parameters you can add to eclipse.ini -- this is from project lombok, where they stumbled upon the same problem with jdk 16, but it's an example of some command line options that could give you a hint where to continue:
Check out stackoverflow-question 65380359 (sorry, I'm not allowed to paste a link)
If you want to dig in deeper, here's some background in the oracle documentation:
The Oracle-documentation with GUID-7744EF96-5899-4FB2-B34E-86D49B2E89B6 has more information on the background of all this.
If I'd want to use jdk 16 as jre for eclipse I'd download a full package of any flavor, and check out the most recent eclipse.ini -- looking for add-opens lines.
|
|
|
Powered by
FUDForum. Page generated in 0.04487 seconds