eclipse-jdt / eclipse-jdt/eclipse.jdt.core
The package is accessible from more than one module
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 49
Description
In the sample project:
[exp.zip](https://github.com/user-attachments/files/17825477/exp.zip)
├── `com.company.a`: This bundle uses `Bundle-Classpath` to embed a JAR that contains packages like `javax.lang.model.element`.
└── `com.company.b`: This bundle uses `Import-Package` to explicitly import the `com.company.util` package from bundle a.
In bundle `b`, there is code that imports `javax.lang.model.element.Element`. However, ECJ reports the following error:
> "The package javax.lang.model.element is accessible from more than one module: , java.compiler."
This occurs because the package `javax.lang.model.element` is present in both the embedded JAR of bundle `a` and the JRE.
From the perspective of the OSGi classloader, bundle `b` should only have access to the packages of bundle `a` that it explicitly declares in its `Import-Package` directive. However, it seems that ECJ does not strictly adhere to OSGi classloader semantics. Instead, it includes all the packages of bundle `a` in the classpath of bundle `b` during compilation, leading to the conflict.
Contributor guide
Assessment
This issue has not been assessed yet.