Skip to content

Commit 4344784

Browse files
committed
Fix BaseImportTestCase on JDK 21+ by ignoring internal modules not on classpath
JDK 21+ exposes internal modules (e.g., jdk.management.agent) that appear as package fragment roots but throw JavaModelException when accessed because they are not on the project's build path. This change explicitly ignores these exceptions to prevent test failures.
1 parent 734020c commit 4344784

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/BaseImportTestCase.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.eclipse.core.runtime.IStatus;
3535
import org.eclipse.core.runtime.Platform;
3636
import org.eclipse.jdt.core.IClasspathEntry;
37+
import org.eclipse.jdt.core.IJavaModelStatusConstants;
3738
import org.eclipse.jdt.core.IJavaProject;
3839
import org.eclipse.jdt.core.IPackageFragmentRoot;
3940
import org.eclipse.jdt.core.JavaCore;
@@ -199,7 +200,15 @@ private void verifyProject(IPluginModelBase modelImported, boolean isJava) throw
199200

200201
private void assertSourceAttached(IJavaProject jProject) throws CoreException {
201202
for (IPackageFragmentRoot root : jProject.getPackageFragmentRoots()) {
202-
IClasspathEntry entry = root.getRawClasspathEntry();
203+
IClasspathEntry entry;
204+
try {
205+
entry = root.getRawClasspathEntry();
206+
} catch (JavaModelException e) {
207+
if (e.getStatus().getCode() == IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH) {
208+
continue;
209+
}
210+
throw e;
211+
}
203212
if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY
204213
|| (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER)
205214
&& !entry.getPath().equals(PDECore.REQUIRED_PLUGINS_CONTAINER_PATH)) {

0 commit comments

Comments
 (0)