-
Notifications
You must be signed in to change notification settings - Fork 65
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
Support hiding some JRE packages from the plugin #696
Comments
@testforstephen due to technical limitations you cannot "replace" any package from the |
JustJ provides JREs that include javac: https://eclipse.dev/justj/?page=documentation I wonder if you can't just reuse that. As @laeubi suggests, I don't think your use case can be supported... |
@merks @laeubi thanks for the response. Our project (JDT language server) uses javac API directly rather than invoking the javac.exe. The namespaces provided by the javac API are in the If there is no existing solution for it yet, would it be possible to use a custom classloader to prioritize loading our local version over the JRE’s? Or could we extend the MANIFEST.MF to support an attribute like |
|
I think you should check out what the JDT project is doing to enable using javac for building the abstract syntax tree. Maybe they already solved this problem? |
@laeubi I have configured the local javac.jar path in both However, during debugging the bundle, the Java runtime prioritizes the system module when finding javac api classes. I use the Java command line parameters I will take a look at
@merks JDT is using ECJ (Eclipse Compiler for Java) to build AST, the thing we're doing is to make JDT to support an alternative parser/compiler (e.g. javac). |
I suggest you revisit what jdt is doing now because it’s doing exactly what you just stated. |
@merks What you speak about is being done in subproject of jdt - jdt.ls (https://projects.eclipse.org/projects/eclipse.jdt.ls) and is not (yet!) part of main jdt. Also @testforstephen is one of the main drivers of that works and his request is in order to make this work easier. |
@testforstephen Its a bit hard to guess what happens, maybe you can share a small example? In general the class-loading works like described here: https://docs.osgi.org/specification/osgi.core/8.0.0/framework.module.html#i3174728 and as mentioned above, the only package that can't be overridden is |
I agree with @laeubi there must be something strange with your bundle. Like requiring the system bundle or Something like that will prevent you from loading the packages from your bundle's class path. |
Use Case:
I'm working on a project that leverages javac as both a parser and compiler to provide Java language support. Previously, our tool relied on the javac bundled with the installed JDK, requiring users to install the latest JDK to get the new feature support. To eliminate this dependency, we are trying to embed a standalone javac JAR in our plugin to provide these capabilities independently of the system JDK.
However, a challenge arises because the embedded javac JAR contains classes that overlap with those in JRE modules, such as java.compiler and jdk.compiler. In practice, the JRE's classes take precedence, so the plugin classloader prioritizes the JRE versions of these classes over those in our embedded javac.
I'm looking for guidance on whether the OSGi platform provides a way to hide specific packages on the classpath from the plugin and allow it to use its own versions of overlapping classes.
The text was updated successfully, but these errors were encountered: