Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Langer2019-12-08 17:38:01 -0500
committerVikas Chandra2019-12-16 03:23:12 -0500
commit3ff9186163506e12e3283335bc32f49dad643c22 (patch)
tree2e981cc8ccda915a3e27177c0021fb3a819800e7
parentbea783c841d5c85a86f047b715181e363e74ba62 (diff)
downloadeclipse.jdt.core-3ff9186163506e12e3283335bc32f49dad643c22.tar.gz
eclipse.jdt.core-3ff9186163506e12e3283335bc32f49dad643c22.tar.xz
eclipse.jdt.core-3ff9186163506e12e3283335bc32f49dad643c22.zip
Bug 558004 - Several NPEs when compiling module declarations afterI20191216-1805
549855 Change-Id: I7fda5a76775ce8b627bcbae4f027a778de15b55b Signed-off-by: Christoph Langer <christoph.langer@sap.com>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java25
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java10
2 files changed, 31 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
index 4c83d917ee..f94c7492cf 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
@@ -8689,6 +8689,31 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
deleteProject("lib");
}
}
+
+ public void testBug558004() throws CoreException {
+ IJavaProject prj = createJava9Project("A");
+ try {
+ String moduleinfopath = "A/src/module-info.java";
+ String moduleinfosrc =
+ "/**\n" +
+ " * The {@link java.nio.file.FileSystems#newFileSystem FileSystems.newFileSystem(URI.create(\"jrt:/\"))}\n" +
+ " */\n" +
+ "module modulartest11 {\n" +
+ "}\n";
+ createFile(moduleinfopath, moduleinfosrc);
+ getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ assertNoErrors();
+ this.problemRequestor.initialize(moduleinfosrc.toCharArray());
+ getCompilationUnit("A/src/module-info.java").getWorkingCopy(this.wcOwner, null);
+ assertProblems("unexpected problems",
+ "----------\n" +
+ "----------\n",
+ this.problemRequestor);
+ } finally {
+ deleteProject(prj);
+ }
+ }
+
public void testBug547479() throws CoreException {
int max = org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java
index 087d33fc8f..c00df74cae 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java
@@ -423,7 +423,8 @@ public class Javadoc extends ASTNode {
scope.problemReporter().javadocInvalidValueReference(fieldRef.sourceStart, fieldRef.sourceEnd, scopeModifiers);
}
else if (fieldRef.actualReceiverType != null) {
- if (scope.enclosingSourceType().isCompatibleWith(fieldRef.actualReceiverType)) {
+ SourceTypeBinding stb = scope.enclosingSourceType();
+ if (stb != null && stb.isCompatibleWith(fieldRef.actualReceiverType)) {
fieldRef.bits |= ASTNode.SuperAccess;
}
ReferenceBinding resolvedType = (ReferenceBinding) fieldRef.actualReceiverType;
@@ -964,8 +965,9 @@ public class Javadoc extends ASTNode {
ClassScope topLevelScope = scope.classScope();
// when scope is not on compilation unit type, then inner class may not be visible...
- if (topLevelScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE ||
- !CharOperation.equals(topLevelType.sourceName, topLevelScope.referenceContext.name)) {
+ if (topLevelScope != null &&
+ (topLevelScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE ||
+ !CharOperation.equals(topLevelType.sourceName, topLevelScope.referenceContext.name))) {
topLevelScope = topLevelScope.outerMostClassScope();
if (typeReference instanceof JavadocSingleTypeReference) {
// inner class single reference can only be done in same unit
@@ -1014,7 +1016,7 @@ public class Javadoc extends ASTNode {
// partially qualified references from a different CU should be warned
char[][] typeRefName = ((JavadocQualifiedTypeReference) typeReference).getTypeName();
int skipLength = 0;
- if (topLevelScope.getCurrentPackage() == resolvedType.getPackage()
+ if (topLevelScope != null && topLevelScope.getCurrentPackage() == resolvedType.getPackage()
&& typeRefName.length < computedCompoundName.length) {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=221539: references can be partially qualified
// in same package and hence if the package name is not given, ignore package name check

Back to the top