Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2016-06-15 19:58:15 +0000
committerTill Brychcy2016-06-15 19:58:15 +0000
commite8351b891768459b45fcffb1834de23e13352047 (patch)
treea56a72b95181be93cb9d8aa4bedaab61b4e42257
parent0810352c93bed0621311cfa8cb1ea4020e54ee8b (diff)
downloadeclipse.jdt.core-e8351b891768459b45fcffb1834de23e13352047.tar.gz
eclipse.jdt.core-e8351b891768459b45fcffb1834de23e13352047.tar.xz
eclipse.jdt.core-e8351b891768459b45fcffb1834de23e13352047.zip
Bug 495635 - [null] NPE in TypeVariableBinding.evaluateNullAnnotations
Change-Id: I749746456b928423e1cecf03a66f9a5b26c8b9c9 Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java50
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java2
3 files changed, 54 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java
index 52a3883949..9756e12e64 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 GK Software AG and others.
+ * Copyright (c) 2011, 2016 GK Software AG 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
@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModelMarker;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
@@ -757,4 +758,51 @@ public class NullAnnotationModelTests extends ReconcilerTests {
deleteProject(project);
}
}
+
+ public void testBug495635() throws CoreException, IOException, InterruptedException {
+ IJavaProject project = null;
+ try {
+ project = createJavaProject("Bug495635", new String[] {"src"}, new String[] {"JCL18_LIB", this.ANNOTATION_LIB}, "bin", "1.8");
+ project.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
+ project.setOption(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION, JavaCore.ERROR);
+
+ createFile("/Bug495635/src/AURegObject.java",
+ "public interface AURegObject {}\n"
+ );
+ createFile("/Bug495635/src/AURegKey.java",
+ "public interface AURegKey<O extends AURegObject> {}\n"
+ );
+ createFile("/Bug495635/src/Person.java",
+ "public interface Person<O extends Person<O>> extends AURegObject, PersonKey<O> {}\n"
+ );
+ createFile("/Bug495635/src/PersonKey.java",
+ "public interface PersonKey<O extends Person<?>> extends AURegKey<O> {}\n"
+ );
+
+ setUpWorkingCopy("/Bug495635/src/Person.java",
+ "public interface Person<O extends Person<O>> extends AURegObject, PersonKey<O> {}\n"
+ );
+ assertProblems(
+ "Unexpected problems",
+ "----------\n" +
+ "----------\n"
+ );
+
+ String str = this.workingCopy.getSource();
+
+ int start = str.indexOf("PersonKey");
+ int length = "PersonKey".length();
+
+ IJavaElement[] elements = this.workingCopy.codeSelect(start, length);
+ assertElementsEqual(
+ "Unexpected elements",
+ "PersonKey [in PersonKey.java [in <default> [in src [in Bug495635]]]]",
+ elements
+ );
+
+ } finally {
+ if (project != null)
+ deleteProject(project);
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
index cf77ce485d..fc028aba43 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -249,7 +249,9 @@ public class CaptureBinding extends TypeVariableBinding {
this.tagBits &= ~TagBits.HasTypeVariable;
break;
}
- evaluateNullAnnotations(scope, null);
+ if(scope.environment().usesNullTypeAnnotations()) {
+ evaluateNullAnnotations(scope, null);
+ }
}
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
index 2b3e274656..0fe0324238 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
@@ -929,7 +929,7 @@ public class TypeVariableBinding extends ReferenceBinding {
}
ReferenceBinding[] interfaces = this.superInterfaces;
int length;
- if ((length = interfaces.length) != 0) {
+ if (interfaces != null && (length = interfaces.length) != 0) {
for (int i = length; --i >= 0;) {
ReferenceBinding resolveType = interfaces[i];
long superNullTagBits = NullAnnotationMatching.validNullTagBits(resolveType.tagBits);

Back to the top