Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2016-10-30 12:20:10 +0000
committerStephan Herrmann2016-11-22 19:01:01 +0000
commit2636134a04a09ab2108c3de14e21d4313f8a2cc1 (patch)
tree3a3057f50d412a7da2ca7d6c61324ffd3951ad60
parent091cdf4345ddbbba767a907bad5b1be60d98a12f (diff)
downloadorg.eclipse.objectteams-2636134a04a09ab2108c3de14e21d4313f8a2cc1.tar.gz
org.eclipse.objectteams-2636134a04a09ab2108c3de14e21d4313f8a2cc1.tar.xz
org.eclipse.objectteams-2636134a04a09ab2108c3de14e21d4313f8a2cc1.zip
Bug 506747: NullPointerException in StateHelper.getState
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/model/TypeModel.java12
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java28
3 files changed, 42 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
index c2b7de894..93e377565 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
@@ -168,6 +168,9 @@ abstract public class ReferenceBinding extends AbstractOTReferenceBinding {
this.compatibleCache = prototype.compatibleCache;
this.typeBits = prototype.typeBits;
this.singleAbstractMethod = prototype.singleAbstractMethod;
+//{ObjectTeams: most subclasses need model to be set:
+ this.model = new TypeModel(prototype.model, this);
+// SH}
}
public ReferenceBinding() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/model/TypeModel.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/model/TypeModel.java
index 5580844a6..0dda30c81 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/model/TypeModel.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/model/TypeModel.java
@@ -75,10 +75,20 @@ public class TypeModel extends ModelElement {
{
throw new InternalCompilerError("Unexpectedly missing line number information"); //$NON-NLS-1$
}
+ this._state = new StateMemento();
}
/* Constructor for regular instances. */
public TypeModel (ReferenceBinding bind) {
this._binding = bind;
+ this._state = new StateMemento();
+ }
+ /** clone constructor: */
+ public TypeModel (TypeModel prototype, ReferenceBinding protoBinding) {
+ this._binding = protoBinding;
+ this._state = prototype._state;
+ this._compilerVersion = prototype._compilerVersion;
+ this.weavingScheme = prototype.weavingScheme;
+ this._ast = prototype._ast;
}
/** Store the byte code attribute which maps constant pool entries (Class_info) to type anchors. */
@@ -95,7 +105,7 @@ public class TypeModel extends ModelElement {
private HashSet<ReferenceBinding> _referencedTeams = null;
/** translation state of this model element */
- final public StateMemento _state= new StateMemento();
+ final public StateMemento _state;
/** Record here all types which are defined local to a method (TypeDeclaration). */
private LinkedList<TypeDeclaration> _localPlainTypes = new LinkedList<TypeDeclaration>();
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java
index cec4af716..b3fade6a4 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java
@@ -19,6 +19,7 @@ import java.util.Map;
import junit.framework.Test;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.objectteams.otdt.core.ext.WeavingScheme;
@@ -387,4 +388,31 @@ public class Java8 extends AbstractOTJLDTest {
},
"0b1b2b3b4");
}
+
+ public void testBug506747() {
+ Map<String,String> options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED); // enable AnnotatableTypeSystem
+ runNegativeTest(
+ new String[] {
+ "p/X.java",
+ "package p;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Ann {}\n" +
+ "public class X {\n" +
+ " void m(final @Ann X X) {\n" +
+ " X.Inner i;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in p\\X.java (at line 7)\n" +
+ " X.Inner i;\n" +
+ " ^^^^^^^\n" +
+ "X.Inner cannot be resolved to a type\n" +
+ "----------\n",
+ null, // libs
+ true, // flush
+ options);
+ }
}

Back to the top