Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java34
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java5
2 files changed, 38 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
index b69c75b599..d952bab1cb 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
@@ -5443,4 +5443,38 @@ public void testBug521362_emptyFile() {
false,
"package p1.p2.t3 clashes with class of same name");
}
+ public void testBug550178() throws Exception {
+ Util.flushDirectoryContent(new File(OUTPUT_DIR));
+ String outDir = OUTPUT_DIR + File.separator + "bin";
+ String srcDir = OUTPUT_DIR + File.separator + "src";
+ File modDir = new File(OUTPUT_DIR + File.separator + "mod");
+ createReusableModules(srcDir, outDir, modDir);
+ String moduleLoc = srcDir + File.separator + "mod.three";
+ List<String> files = new ArrayList<>();
+ writeFileCollecting(files, moduleLoc, "module-info.java",
+ "module mod.three { \n" +
+ " exports pkg.invalid;\n" +
+ "}");
+
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("-d " + outDir )
+ .append(" -9 ")
+ .append(" --module-path \"")
+ .append(Util.getJavaClassLibsAsString())
+ .append(modDir.getAbsolutePath())
+ .append("\" ")
+ .append(" --module-source-path " + "\"" + srcDir + "\" ");
+ runNegativeModuleTest(files, buffer,
+ "",
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/mod.three/module-info.java (at line 2)\n" +
+ " exports pkg.invalid;\n" +
+ " ^^^^^^^^^^^\n" +
+ "The package pkg.invalid does not exist or is empty\n" +
+ "----------\n" +
+ "1 problem (1 error)\n",
+ false,
+ "");
+ }
}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
index 0f05fbd865..b59f9fc4bf 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
@@ -318,7 +318,10 @@ public boolean hasCompilationUnit(String qualifiedPackageName, String moduleName
@Override
public boolean hasCUDeclaringPackage(String qualifiedPackageName, Function<CompilationUnit, String> pkgNameExtractor) {
String qp2 = File.separatorChar == '/' ? qualifiedPackageName : qualifiedPackageName.replace('/', File.separatorChar);
- return Stream.of(directoryList(qp2)).anyMatch(entry -> {
+ String[] directoryList = directoryList(qp2);
+ if(directoryList == null)
+ return false;
+ return Stream.of(directoryList).anyMatch(entry -> {
String entryLC = entry.toLowerCase();
boolean hasDeclaration = false;
String fullPath = this.path + qp2 + "/" + entry; //$NON-NLS-1$

Back to the top