diff options
author | Stephan Herrmann | 2018-02-22 12:31:11 +0000 |
---|---|---|
committer | Stephan Herrmann | 2019-09-15 18:12:25 +0000 |
commit | 6a8cee1126829229d648db4ae0e5a6b70a5d4f13 (patch) | |
tree | c0e1968ac030d144804cd9f977a69d47e4fad7d4 | |
parent | 3352ea19a938f5fae692626b92186d9cd021a219 (diff) | |
download | eclipse.jdt.core-6a8cee1126829229d648db4ae0e5a6b70a5d4f13.tar.gz eclipse.jdt.core-6a8cee1126829229d648db4ae0e5a6b70a5d4f13.tar.xz eclipse.jdt.core-6a8cee1126829229d648db4ae0e5a6b70a5d4f13.zip |
Bug 531536 - Another NPE in Annotation.isTypeUseCompatible() due toI20190918-0300I20190917-1800I20190916-1800I20190915-1800
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); } |