Open bvlj opened 3 months ago
Why do you use jdt.core and not jdt batch compiler directly?
Assuming you're referring to using the classes under the org.eclipse.jdt.internal.compiler.batch
package (which should come from org.eclipse.jdt.ejc
if I understand correctly), rather than those in org.eclipse.jdt.core.dom
: I can't find an "equivalent" of the org.eclipse.jdt.core.dom.ASTParser
class in the former
OK, I see, you want have AST, not just compiler. I assume there is no way to use modules for jdt.core now, as we share some packages with batch compiler and so violate "module" rules.
I guess the only viable solution for the world outside of the OSGI would be to provide "merged" JDT module (batch + core) deployed to maven?
@stephan-herrmann : any comments on that?
OK, I see, you want have AST, not just compiler. I assume there is no way to use modules for jdt.core now, as we share some packages with batch compiler and so violate "module" rules.
I guess the only viable solution for the world outside of the OSGI would be to provide "merged" JDT module (batch + core) deployed to maven?
@stephan-herrmann : any comments on that?
I assume the task is invoking ASTParser from within a JPMS module, right?
In that case, org.eclipse.jdt.core
must indeed be referenced (required) as an automatic module. But it is possible to use --patch-module
to link in also org.eclipse.jdt.core.compiler.batch
alias ecj
(with appropriate paths to the jar files):
$ java -p org.eclipse.jdt.core_3.39.0.v20240724-1734.jar --add-modules org.eclipse.jdt.core --patch-module org.eclipse.jdt.core=org.eclipse.jdt.core.compiler.batch_3.39.0.v20240725-1906.jar org.eclipse.jdt.internal.compiler.batch.Main -help
I assume the above workaround with --patch-module
is the best we can offer.
Ok, thanks for the information 👍
When using the jdt.core library as a dependency (
org.eclipse.jdt:org.eclipse.jdt.core:3.38.0
from maven central) to a Java 21 Gradle project which also makes use of the Java module system, the compilation fails due to a number of packages being provided multiple times by the library.Excerpt of build output:
Example of a
module-info.java
of the module that makes use of the jdt library:I have provided a repository which should help you reproduce and investigate the issue here: https://github.com/bvlj/eclipse_jdt_issue_module