Bug 454182 - Internal compiler error when using 1.8 compliance for
simple project
Change-Id: Ied37dfb4ce8dfd7c358dbe1eb7b82f9435c0f63a
Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
index c506289..4bc3980 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
+import java.io.File;
import java.util.Map;
import junit.framework.Test;
@@ -7541,4 +7542,22 @@
"Null type mismatch: required \'@NonNull String\' but the provided value is inferred as @Nullable\n" +
"----------\n");
}
+public void testBug454182() {
+
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME, "annot.NonNullByDefault");
+ String[] libs = this.LIBS.clone();
+ libs[libs.length-1] = this.getCompilerTestsPluginDirectoryPath() + File.separator + "workspace" + File.separator + "Test454182.jar";
+ runConformTest(
+ new String[] {
+ "p/package-info.java",
+ "@annot.NonNullByDefault package p;\n"
+ },
+ "",
+ libs,
+ false,
+ null,
+ options,
+ null);
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/workspace/Test454182.jar b/org.eclipse.jdt.core.tests.compiler/workspace/Test454182.jar
new file mode 100644
index 0000000..d26c471
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/workspace/Test454182.jar
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
index 20a634d..d2662d5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -32,6 +32,7 @@
* Bug 441693 - [1.8][null] Bogus warning for type argument annotated with @NonNull
* Bug 435805 - [1.8][compiler][null] Java 8 compiler does not recognize declaration style null annotations
* Bug 453475 - [1.8][null] Contradictory null annotations (4.5 M3 edition)
+ * Bug 454182 - Internal compiler error when using 1.8 compliance for simple project
* Jesper Steen Moller - Contributions for
* Bug 412150 [1.8] [compiler] Enable reflected parameter names during annotation processing
* Bug 412153 - [1.8][compiler] Check validity of annotations which may be repeatable
@@ -1591,6 +1592,9 @@
if (nonNullByDefaultAnnotationName == null)
return; // not well-configured to use null annotations
+ if (CharOperation.equals(CharOperation.splitOn('/', binaryType.getName()), nonNullByDefaultAnnotationName))
+ return; // don't recursively apply @NNBD on @NNBD, neither directly nor via the 'enclosing' package-info.java
+
IBinaryAnnotation[] annotations = binaryType.getAnnotations();
boolean isPackageInfo = CharOperation.equals(sourceName(), TypeConstants.PACKAGE_INFO_NAME);
if (annotations != null) {