Bug 533488 - [9] @Deprecated may cause AIOOBE
Change-Id: I3f61e194da38f4105e34aab5226d5f688af6ec9f
Signed-off-by: Alexander Leshkin <alexander.leshkin@gmail.com>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest_9.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest_9.java
new file mode 100644
index 0000000..27dbb97
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest_9.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+
+import junit.framework.Test;
+
+@SuppressWarnings({ "rawtypes" })
+public class AnnotationTest_9 extends AbstractComparableTest {
+
+ public AnnotationTest_9(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_9);
+ }
+
+ public static Class testClass() {
+ return AnnotationTest_9.class;
+ }
+
+ public void testBug532913() throws Exception {
+ this.complianceLevel = ClassFileConstants.JDK9;
+ if (this.complianceLevel < ClassFileConstants.JDK9) {
+ return;
+ }
+
+ runConformTest(
+ new String[] {
+ "p/A.java",
+ "package p;\n" +
+ "@java.lang.annotation.Target({\n" +
+ " java.lang.annotation.ElementType.TYPE, java.lang.annotation.ElementType.METHOD})\n" +
+ "@Deprecated\n" +
+ "public @interface A {}\n",
+ },"");
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import p.A;\n" +
+ "class X {\n" +
+ " @A void foo() {}\n" +
+ "}\n",
+ },"", null, false, null);
+ }
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
index 6f6cecb..2d39189 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
@@ -76,7 +76,7 @@
result[index++] = buildTargetAnnotation(annotationTagBits, env);
if ((annotationTagBits & TagBits.AnnotationRetentionMASK) != 0)
result[index++] = buildRetentionAnnotation(annotationTagBits, env);
- if ((annotationTagBits & TagBits.AnnotationDeprecated) != 0)
+ if (!haveDeprecated && (annotationTagBits & TagBits.AnnotationDeprecated) != 0)
result[index++] = buildMarkerAnnotation(TypeConstants.JAVA_LANG_DEPRECATED, env.javaBaseModule(), env);
if ((annotationTagBits & TagBits.AnnotationDocumented) != 0)
result[index++] = buildMarkerAnnotation(TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED, env.javaBaseModule(), env);