diff options
| author | Stephan Herrmann | 2012-07-11 20:07:21 +0000 |
|---|---|---|
| committer | Jayaprakash Arthanareeswaran | 2012-08-10 06:57:09 +0000 |
| commit | 43546c964bf895e47ee49e1c06b426c032d0e84c (patch) | |
| tree | 55ea21a5abf51e044f2f1bd4effb16a844b5ca55 | |
| parent | 731853ec9e7c1643b53886677c02a30ab137fa8d (diff) | |
| download | eclipse.jdt.core-43546c964bf895e47ee49e1c06b426c032d0e84c.tar.gz eclipse.jdt.core-43546c964bf895e47ee49e1c06b426c032d0e84c.tar.xz eclipse.jdt.core-43546c964bf895e47ee49e1c06b426c032d0e84c.zip | |
Test & fix for bug 384870 - [compiler] @Deprecated annotation not
detected if preceded by other annotation
2 files changed, 35 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java index f503888f7f..20b8825250 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java @@ -7,7 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for Bug 354536 - compiling package-info.java still depends on the order of compilation units + * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contributions for + * bug 354536 - compiling package-info.java still depends on the order of compilation units + * bug 384870 - [compiler] @Deprecated annotation not detected if preceded by other annotation *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; @@ -266,6 +268,36 @@ public void test005() { "----------\n", JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); } +// https://bugs.eclipse.org/384870 - [compiler] @Deprecated annotation not detected if preceded by other annotation +public void test006() { + Map customOptions = new HashMap(); + customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); + this.runNegativeTest( + true, + new String[] { + "test1/E02.java", + "package test1;\n" + + "public class E02 {\n" + + " public void foo(E01 arg) {\n" + + " // nop\n" + + " }\n" + + "}", + "test1/E01.java", + "package test1;\n" + + "@SuppressWarnings(\"all\") @Deprecated\n" + + "public class E01 {\n" + + " public static int x = 5;\n" + + "}" + }, + null, customOptions, + "----------\n" + + "1. ERROR in test1\\E02.java (at line 3)\n" + + " public void foo(E01 arg) {\n" + + " ^^^\n" + + "The type E01 is deprecated\n" + + "----------\n", + JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); +} public static Class testClass() { return Deprecated15Test.class; } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java index 92eba1436d..e4bd6c8708 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java @@ -18,6 +18,7 @@ * bug 186342 - [compiler][null] Using annotations for null checking * bug 365519 - editorial cleanup after bug 186342 and bug 365387 * bug 374605 - Unreasonable warning for enum-based switch statements + * bug 384870 - [compiler] @Deprecated annotation not detected if preceded by other annotation *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -902,7 +903,7 @@ public static void resolveDeprecatedAnnotations(BlockScope scope, Annotation[] a for (int i = 0; i < length; i++) { TypeReference annotationTypeRef = annotations[i].type; // only resolve type name if 'Deprecated' last token - if (!CharOperation.equals(TypeConstants.JAVA_LANG_DEPRECATED[2], annotationTypeRef.getLastToken())) return; + if (!CharOperation.equals(TypeConstants.JAVA_LANG_DEPRECATED[2], annotationTypeRef.getLastToken())) continue; TypeBinding annotationType = annotations[i].type.resolveType(scope); if(annotationType != null && annotationType.isValidBinding() && annotationType.id == TypeIds.T_JavaLangDeprecated) { switch (kind) { |
