Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Milles2020-06-25 09:29:01 -0400
committerRoland Grunberg2020-07-02 12:23:49 -0400
commit122694ee3b5047570938dbfc4e33a10c65d69d48 (patch)
treed90aacb7d3ae7f8202842395652cb0fa3fe18866
parent426eda83ab55bcae1ac579d54780ff57822b5a3c (diff)
downloadeclipse.jdt.core-122694ee3b5047570938dbfc4e33a10c65d69d48.tar.gz
eclipse.jdt.core-122694ee3b5047570938dbfc4e33a10c65d69d48.tar.xz
eclipse.jdt.core-122694ee3b5047570938dbfc4e33a10c65d69d48.zip
Bug 564591 - ParameterizedTypeBinding drops annos from ReferenceBindingI20200702-2150I20200702-1800
Change-Id: Ida20911d6a98d81dc50eea77af2fc5b81ddb4821 Signed-off-by: Eric Milles <eric.milles@thomsonreuters.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TypeAnnotationTest.java27
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java8
2 files changed, 29 insertions, 6 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TypeAnnotationTest.java
index 1021a161ef..29b91a9510 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TypeAnnotationTest.java
@@ -33,6 +33,7 @@ import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
@@ -57,8 +58,8 @@ public class TypeAnnotationTest extends AbstractRegressionTest {
// Enables the tests to run individually
@Override
- protected Map getCompilerOptions() {
- Map defaultOptions = super.getCompilerOptions();
+ protected Map<String, String> getCompilerOptions() {
+ Map<String, String> defaultOptions = super.getCompilerOptions();
defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8);
defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8);
defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
@@ -6942,5 +6943,25 @@ public class TypeAnnotationTest extends AbstractRegressionTest {
assertEquals("Base.Static.@A2 Static2<@B1 Exception>.@A3 Middle1.@A4 Middle2<@B2 Class<@C1 Object @C2 []> @B3 []>.@A5 Middle3.@A6 GenericInner<@B4 String> @A7 [] @A8 []",
new String(methods3[0].parameters[0].annotatedDebugName()));
}
-}
+ public void testBug594561_ParameterizedTypeAnnotations() {
+ runConformTest(new String[] {
+ "p/C.java",
+ "package p;" +
+ "@Deprecated\n" +
+ "abstract class A<T> {}\n" +
+ "class C extends A<String> {}\n",
+ });
+
+ Requestor requestor = new Requestor(false, null, false, false);
+ Map<String, String> customOptions = getCompilerOptions(); customOptions.put(CompilerOptions.OPTION_Store_Annotations, CompilerOptions.ENABLED);
+ Compiler compiler = new Compiler(getNameEnvironment(new String[0], null), getErrorHandlingPolicy(), new CompilerOptions(customOptions), requestor, getProblemFactory());
+
+ ReferenceBinding type = compiler.lookupEnvironment.askForType(new char[][] {"p".toCharArray(), "C".toCharArray()}, compiler.lookupEnvironment.UnNamedModule);
+ assertNotNull(type);
+
+ AnnotationBinding[] annos = type.superclass().getAnnotations();
+ assertEquals(1, annos.length);
+ assertEquals("java.lang.Deprecated", annos[0].getAnnotationType().debugName());
+ }
+}
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 8a3d74fe86..2eaa03ca90 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
@@ -661,9 +661,11 @@ public class ParameterizedTypeBinding extends ReferenceBinding implements Substi
return this.genericTypeSignature;
}
- /**
- * @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#getAnnotationTagBits()
- */
+ @Override
+ public AnnotationBinding[] getAnnotations() {
+ return this.type.getAnnotations();
+ }
+
@Override
public long getAnnotationTagBits() {
return this.type.getAnnotationTagBits();

Back to the top