diff options
author | Stephan Herrmann | 2018-02-22 12:31:11 +0000 |
---|---|---|
committer | Manoj Palat | 2019-09-20 09:56:14 +0000 |
commit | c42780677a2065b0d31b0ccd7a3dd4caa49c9fbc (patch) | |
tree | c5bbd4156242b8d2fa9405d9c756f3802a7bcf59 | |
parent | 2d3a761cebc24c4885141bab20f0ee2f607829bf (diff) | |
download | eclipse.jdt.core-c42780677a2065b0d31b0ccd7a3dd4caa49c9fbc.tar.gz eclipse.jdt.core-c42780677a2065b0d31b0ccd7a3dd4caa49c9fbc.tar.xz eclipse.jdt.core-c42780677a2065b0d31b0ccd7a3dd4caa49c9fbc.zip |
Bug 531536 - Another NPE in Annotation.isTypeUseCompatible() due to
unhappy re-entrance
Change-Id: Ia7bf97b4fca176f7af944a0b9435853732a43fb0
2 files changed, 45 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java index 7af73780a3..9ef55a2e05 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java @@ -12203,4 +12203,43 @@ public void testBug546084c() throws Exception { }; runner.runConformTest(); } +public void testBug490698_comment16() { + runConformTest( + new String[] { + "foo/bar/AnnotationError.java", + "package foo.bar;\n" + + "\n" + + "import static java.lang.annotation.ElementType.FIELD;\n" + + "import static java.lang.annotation.RetentionPolicy.RUNTIME;\n" + + "\n" + + "import java.lang.annotation.Retention;\n" + + "import java.lang.annotation.Target;\n" + + "import java.util.function.Predicate;\n" + + "\n" + + "public class AnnotationError<T> {\n" + + "\n" + + " public enum P {\n" + + " AAA\n" + + " }\n" + + "\n" + + " @Target(FIELD)\n" + + " @Retention(RUNTIME)\n" + + " public @interface A {\n" + + " P value();\n" + + " }\n" + + "\n" + + " @Target(FIELD)\n" + + " @Retention(RUNTIME)\n" + + " public @interface FF {\n" + + " }\n" + + "\n" + + " public static class Bool extends AnnotationError<Boolean> {\n" + + " }\n" + + "\n" + + " @A(P.AAA)\n" + + " @FF\n" + + " public static final AnnotationError.Bool FOO = new AnnotationError.Bool();\n" + + "}\n" + }); +} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java index 6fba803083..09aca3df68 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java @@ -784,6 +784,12 @@ public class ParameterizedTypeBinding extends ReferenceBinding implements Substi */ @Override public FieldBinding getField(char[] fieldName, boolean needResolve) { + if (((this.tagBits & TagBits.AreFieldsComplete) == 0) && ((this.type.tagBits & TagBits.AreFieldsSorted) != 0)) { + // assume that completing fields is in progress + FieldBinding originalField = ReferenceBinding.binarySearch(fieldName, this.type.unResolvedFields()); + if (originalField == null) + return null; // avoid useless, possibly premature resolving + } fields(); // ensure fields have been initialized... must create all at once unlike methods return ReferenceBinding.binarySearch(fieldName, this.fields); } |