Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2016-06-15 19:58:15 +0000
committerStephan Herrmann2016-08-09 11:04:38 +0000
commitb789afe530d50c1b1770698f09bbacfff70907bb (patch)
tree908973085739265b28318c501cb803fb56747a54
parent4755b42a8fa5164de0e73890525094ed1792c112 (diff)
downloadeclipse.jdt.core-b789afe530d50c1b1770698f09bbacfff70907bb.tar.gz
eclipse.jdt.core-b789afe530d50c1b1770698f09bbacfff70907bb.tar.xz
eclipse.jdt.core-b789afe530d50c1b1770698f09bbacfff70907bb.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/META-INF/MANIFEST.MF2
-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
-rw-r--r--org.eclipse.jdt.core/pom.xml2
5 files changed, 56 insertions, 6 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/META-INF/MANIFEST.MF b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
index 67e855bfc2..744ae13355 100644
--- a/org.eclipse.jdt.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Main-Class: org.eclipse.jdt.internal.compiler.batch.Main
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core; singleton:=true
-Bundle-Version: 3.12.0.qualifier
+Bundle-Version: 3.12.1.qualifier
Bundle-Activator: org.eclipse.jdt.core.JavaCore
Bundle-Vendor: %providerName
Bundle-Localization: plugin
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);
diff --git a/org.eclipse.jdt.core/pom.xml b/org.eclipse.jdt.core/pom.xml
index 23cb650542..ff8fed3b53 100644
--- a/org.eclipse.jdt.core/pom.xml
+++ b/org.eclipse.jdt.core/pom.xml
@@ -18,7 +18,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
- <version>3.12.0-SNAPSHOT</version>
+ <version>3.12.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>

Back to the top