|
26 | 26 | import java.util.Map;
|
27 | 27 | import java.util.regex.Pattern;
|
28 | 28 | import junit.framework.Test;
|
| 29 | +import org.eclipse.core.resources.IMarker; |
| 30 | +import org.eclipse.core.resources.IResource; |
29 | 31 | import org.eclipse.core.resources.IncrementalProjectBuilder;
|
30 | 32 | import org.eclipse.core.runtime.CoreException;
|
31 | 33 | import org.eclipse.core.runtime.IPath;
|
@@ -783,6 +785,10 @@ public void testSystemLibAsJMod() throws Exception {
|
783 | 785 | IPath path = rawClasspath[i].getPath();
|
784 | 786 | if (path.lastSegment().equals("jrt-fs.jar")) {
|
785 | 787 | path = path.removeLastSegments(2).append("jmods").append("java.base.jmod");
|
| 788 | + if (path.toFile().exists()) { |
| 789 | + // No jmod files in JDK? This test is not applicable |
| 790 | + return; |
| 791 | + } |
786 | 792 | IClasspathEntry newEntry = newModularLibraryEntry(path, rawClasspath[i].getSourceAttachmentPath(), new Path("java.base"));
|
787 | 793 | rawClasspath[i] = newEntry;
|
788 | 794 | }
|
@@ -838,6 +844,10 @@ public void test515342b() throws Exception {
|
838 | 844 | IPath path = rawClasspath[i].getPath();
|
839 | 845 | if (path.lastSegment().equals("jrt-fs.jar")) {
|
840 | 846 | path = path.removeLastSegments(2).append("jmods").append("java.base.jmod");
|
| 847 | + if (!path.toFile().exists()) { |
| 848 | + // No jmod files? Then this test is not applicable |
| 849 | + return; |
| 850 | + } |
841 | 851 | IClasspathEntry newEntry = newModularLibraryEntry(path, rawClasspath[i].getSourceAttachmentPath(), new Path("java.base"));
|
842 | 852 | rawClasspath[i] = newEntry;
|
843 | 853 | }
|
@@ -1430,6 +1440,11 @@ private IJavaProject createJavaProjectWithBaseSql() throws CoreException {
|
1430 | 1440 | IPath path = rawClasspath[i].getPath();
|
1431 | 1441 | if (path.lastSegment().equals("jrt-fs.jar")) {
|
1432 | 1442 | path = path.removeLastSegments(2).append("jmods").append("java.base.jmod");
|
| 1443 | + if (!path.toFile().exists()) { |
| 1444 | + // No jmod files? Just proceed with the jrt-fs. |
| 1445 | + newClasspath[i] = rawClasspath[i]; |
| 1446 | + continue; |
| 1447 | + } |
1433 | 1448 | IClasspathEntry newEntry = JavaCore.newLibraryEntry(path, rawClasspath[i].getSourceAttachmentPath(), new Path("java.base"));
|
1434 | 1449 | newClasspath[i] = newEntry;
|
1435 | 1450 | path = path.removeLastSegments(2).append("jmods").append("java.sql.jmod");
|
@@ -1601,6 +1616,10 @@ public void test530024_001() throws Exception {
|
1601 | 1616 | if (path.lastSegment().equals("jrt-fs.jar")) {
|
1602 | 1617 | jdkRootPath = path.removeLastSegments(2);
|
1603 | 1618 | path = jdkRootPath.append("jmods").append("java.base.jmod");
|
| 1619 | + if (!path.toFile().exists()) { |
| 1620 | + // No jmod files? Then this test is not applicable |
| 1621 | + return; |
| 1622 | + } |
1604 | 1623 | IClasspathEntry newEntry = newModularLibraryEntry(path, rawClasspath[i].getSourceAttachmentPath(), new Path("java.base"));
|
1605 | 1624 | rawClasspath[i] = newEntry;
|
1606 | 1625 | }
|
@@ -1725,4 +1744,12 @@ public void test530653() throws CoreException, IOException {
|
1725 | 1744 | deleteProject("Java9Elements");
|
1726 | 1745 | }
|
1727 | 1746 | }
|
| 1747 | + public void testGH3549() throws CoreException, IOException { |
| 1748 | + IJavaProject project = setUpJavaProject("JModTests", "17"); |
| 1749 | + waitForManualRefresh(); |
| 1750 | + waitForAutoBuild(); |
| 1751 | + project.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null); |
| 1752 | + IMarker[] markers = project.getProject().findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); |
| 1753 | + assertMarkers("unexpected markers", "mod.c cannot be resolved to a module", markers); |
| 1754 | + } |
1728 | 1755 | }
|
0 commit comments