diff options
2 files changed, 26 insertions, 3 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 d9eaef7286..8c553c7bb1 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 @@ -37,7 +37,7 @@ import junit.framework.Test; public class ModuleCompilationTests extends AbstractBatchCompilerTest { static { -// TESTS_NAMES = new String[] { "testPackageConflict4a" }; +// TESTS_NAMES = new String[] { "test_npe_bug535107" }; // TESTS_NUMBERS = new int[] { 1 }; // TESTS_RANGE = new int[] { 298, -1 }; } @@ -4903,4 +4903,26 @@ public void testBug521362_emptyFile() { String fileName = OUTPUT_DIR + File.separator + out + File.separator + "mod.one" + File.separator + "module-info.class"; assertClassFile("Missing modul-info.class: " + fileName, fileName, classFiles); } + public void test_npe_bug535107() { + runConformModuleTest( + new String[] { + "p/X.java", + "package p;\n" + + "import java.lang.annotation.*;\n" + + "@Target(ElementType.MODULE)\n" + + "public @interface X {\n" + + " ElementType value();\n" + + "}", + "module-info.java", + "import java.lang.annotation.*;\n" + + "@p.X(ElementType.MODULE)\n" + + "module mod.one { \n" + + "}" + }, + " -9 \"" + OUTPUT_DIR + File.separator + "module-info.java\" " + + "\"" + OUTPUT_DIR + File.separator + "p/X.java\"", + "", + "", + true); + } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java index 6c314cc818..7e4de63b6b 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1062,7 +1062,8 @@ public TypeBinding resolveType(BlockScope scope) { // only last field is actually a write access if any // check if accessing enum static field in initializer if (declaringClass.isEnum()) { - if ((TypeBinding.equalsEquals(sourceType, declaringClass) || TypeBinding.equalsEquals(sourceType.superclass, declaringClass)) // enum constant body + if ((TypeBinding.equalsEquals(sourceType, declaringClass) || + (sourceType != null && TypeBinding.equalsEquals(sourceType.superclass, declaringClass))) // enum constant body && fieldBinding.constant(scope) == Constant.NotAConstant && !methodScope.isStatic && methodScope.isInsideInitializerOrConstructor()) { |