Community
Participate
Working Groups
The method OSGiWeavingAdaptor.defineClass still calls the protected method ClassLoader.defineClass(String, byte[],int,int) and defines setAccessible(true) for this method which results in an error with JDK16 if you not not explicitly define --illegal-access=warn/debug. Only defining --add-opens java.base/java.lang=ALL-UNNAMED does not solve the problem. Unfortunately --illegal-access is deprecated and may be removed with JDK17 (https://openjdk.java.net/jeps/403). This JEP lists exactly this problem in its "Risk and Assumptions" section and contains the following description how it has to be solved: "Frameworks that use the protected defineClass methods of java.lang.ClassLoader in order to define new classes in existing class loaders. Such frameworks should instead use java.lang.invoke.MethodHandles.Lookup::defineClass, which has been available since JDK 9." If --illegal-access is really removed in JDK17 we are not able to run our Eclipse RCP applcation with JDK17 which is our intention because JDK17 is the next release containing LTS.
I assume you are referring to org.eclipse.equinox.weaving.aspectj.loadtime.OSGiWeavingAdaptor See bug 470000. This moved to the AspectJ project
Ok, thank, then i will open this bug there
Sorry, i just saw that you have aleady moved the issue to the aspectj project
I am a little bit confused because the Eclipse RCP app having the described problem works fine from within Eclipse IDE with the following definitions --add-opens java.base/java.lang=ALL-UNNAMED --illegal-access=deny so it seems that adding --add-opens java.base/java.lang=ALL-UNNAMED should fix the problem. But when i deploy the app by exporting the product and start it with app.exe the app.ini file generated contains -vmargs --add-opens java.base/java.lang=ALL-UNNAMED --illegal-access=deny but it fails. Can it be that there is only a problem with the native launcher app?
i just found a solution for the problem. If you define -vmargs --add-opens=java.base/java.lang=ALL-UNNAMED --illegal-access=deny then it works also if the rcp app ist started with eclipse.exe
If you are defining classes with the bundle class loader it may be possible to use the public method: org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(String, byte[], ClasspathEntry)