Skip to content

Commit bdac0e0

Browse files
committed
Fix JavaModelException in BaseImportTestCase on JDK 21+
1 parent 734020c commit bdac0e0

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)