diff options
author | Manoj Palat | 2018-05-28 05:19:18 +0000 |
---|---|---|
committer | Manoj Palat | 2018-05-28 05:19:18 +0000 |
commit | eb8f27c4b5bd92e24f851fddbc6a939e097450ab (patch) | |
tree | 20d923e7c92caa4937f417649e4b79e33783e0eb | |
parent | 7a7103893293ccaa08503110334998347e22f2e4 (diff) | |
download | eclipse.jdt.core-I20180603-0800.tar.gz eclipse.jdt.core-I20180603-0800.tar.xz eclipse.jdt.core-I20180603-0800.zip |
Bug 535107 - [9][compiler]NPE while compilation with Annotation S4_8_0_RC4aS4_8_0_RC4S4_8_0_RC3R4_8I20180611-0500I20180607-1630I20180607-0300I20180606-2000I20180606-0800I20180605-2000I20180605-0800I20180605-0430I20180604-2000I20180604-0800I20180603-2000I20180603-0800I20180602-1500I20180602-0800I20180601-2000I20180531-0700I20180530-2000I20180530-0800I20180530-0200I20180530-0035I20180529-2345I20180529-2000I20180529-0800I20180529-0600I20180529-0210I20180528-2020I20180528-2000
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()) { |