Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 209250 Details for
Bug 365437
Private methods tagged with @Inject should not be flagged with unused warning
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v2.1 + regression tests
master--Fixed-bug-365437-Private-methods-tagged-with.patch (text/plain), 35.47 KB, created by
Ayushman Jain
on 2012-01-10 05:52:14 EST
(
hide
)
Description:
proposed fix v2.1 + regression tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2012-01-10 05:52:14 EST
Size:
35.47 KB
patch
obsolete
>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 bbe0ba5..4a8b0fa 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 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -47,7 +47,7 @@ > // Static initializer to specify tests subset using TESTS_* static variables > // All specified tests which do not belong to the class are skipped... > static { >-// TESTS_NAMES = new String[] { "test293" }; >+// TESTS_NAMES = new String[] { "testBug365437" }; > // TESTS_NUMBERS = new int[] { 297 }; > // TESTS_RANGE = new int[] { 294, -1 }; > } >@@ -10148,4 +10148,373 @@ > "Bla cannot be resolved to a type\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 >+public void testBug365437a() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ String testFiles [] = new String[] { >+ "p/A.java", >+ "package p;\n" + >+ "import p1.*;\n" + >+ "public class A {\n" + >+ " @p1.PreDestroy\n" + >+ " private void foo1(){}\n" + >+ " @PreDestroy\n" + >+ " private void foo2(){}\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " @PostConstruct\n" + >+ " private void foo1a(){}\n" + >+ " @PostConstruct\n" + >+ " private void foo2a(){}\n" + >+ " @Deprecated" + >+ " private void foo3(){}" + >+ "}\n", >+ "p1/PreDestroy.java", >+ "package p1;\n" + >+ "public @interface PreDestroy{}", >+ "p1/PostConstruct.java", >+ "package p1;\n" + >+ "public @interface PostConstruct{}" >+ }; >+ String expectedErrorString = >+ "----------\n" + >+ "1. WARNING in p\\A.java (at line 8)\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " ^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"null\")\n" + >+ "----------\n" + >+ "2. ERROR in p\\A.java (at line 13)\n" + >+ " @Deprecated private void foo3(){}}\n" + >+ " ^^^^^^\n" + >+ "The method foo3() from the type A is never used locally\n" + >+ "----------\n"; >+ runNegativeTest( >+ true, >+ testFiles, >+ null, >+ customOptions, >+ expectedErrorString, >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 >+public void testBug365437b() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_AnnotationBasedNullAnalysis, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "p.NonNull"); >+ String testFiles [] = new String[] { >+ "A.java", >+ "import javax.annotation.*;\n" + >+ "public class A {\n" + >+ " @javax.annotation.PreDestroy\n" + >+ " private void foo1(){}\n" + >+ " @PreDestroy\n" + >+ " private void foo2(){}\n" + >+ " @javax.annotation.Resource\n" + >+ " private void foo1a(){}\n" + >+ " @Resource\n" + >+ " @p.NonNull\n" + >+ " private Object foo2a(){ return new Object();}\n" + >+ " @javax.annotation.PostConstruct\n" + >+ " @Deprecated\n" + >+ " private void foo3(){}\n" + >+ " @p.NonNull\n" + >+ " private Object foo3a(){ return new Object();}\n" + >+ "}\n", >+ "p/NonNull.java", >+ "package p;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "import java.lang.annotation.*;\n" + >+ "@Target({TYPE, METHOD,PARAMETER,LOCAL_VARIABLE})\n" + >+ "public @interface NonNull {\n" + >+ "}" >+ }; >+ String expectedErrorString = >+ "----------\n" + >+ "1. ERROR in A.java (at line 16)\n" + >+ " private Object foo3a(){ return new Object();}\n" + >+ " ^^^^^^^\n" + >+ "The method foo3a() from the type A is never used locally\n" + >+ "----------\n"; >+ runNegativeTest( >+ true, >+ testFiles, >+ null, >+ customOptions, >+ expectedErrorString, >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 >+// @SafeVarargs >+public void testBug365437c() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_7) return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ String testFiles [] = new String[] { >+ "p/A.java", >+ "package p;\n" + >+ "import p1.*;\n" + >+ "public class A {\n" + >+ " @p1.PreDestroy\n" + >+ " private void foo1(){}\n" + >+ " @PreDestroy\n" + >+ " private void foo2(){}\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " @PostConstruct\n" + >+ " private void foo1a(){}\n" + >+ " @PostConstruct\n" + >+ " private void foo2a(){}\n" + >+ " @SafeVarargs" + >+ " private final void foo3(Object... o){}" + >+ "}\n", >+ "p1/PreDestroy.java", >+ "package p1;\n" + >+ "public @interface PreDestroy{}", >+ "p1/PostConstruct.java", >+ "package p1;\n" + >+ "public @interface PostConstruct{}" >+ }; >+ String expectedErrorString = >+ "----------\n" + >+ "1. WARNING in p\\A.java (at line 8)\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " ^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"null\")\n" + >+ "----------\n" + >+ "2. ERROR in p\\A.java (at line 13)\n" + >+ " @SafeVarargs private final void foo3(Object... o){}}\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "The method foo3(Object...) from the type A is never used locally\n" + >+ "----------\n"; >+ runNegativeTest( >+ true, >+ testFiles, >+ null, >+ customOptions, >+ expectedErrorString, >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 >+// unused constructor >+public void testBug365437d() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_AnnotationBasedNullAnalysis, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "p.NonNull"); >+ this.runNegativeTest( >+ true, >+ new String[] { >+ "Example.java", >+ "class Example {\n" + >+ " @p.Annot\n" + >+ " private Example() {\n" + >+ " }\n" + >+ " public Example(int i) {\n" + >+ " }\n" + >+ "}\n" + >+ "class E1 {\n" + >+ " @Deprecated\n" + >+ " private E1() {}\n" + >+ " public E1(long l) {}\n" + >+ "}\n" + >+ "class E2 {\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " private E2() {}\n" + >+ " public E2(long l) {}\n" + >+ "}\n" + >+ "class E3 {\n" + >+ " @p.NonNull\n" + >+ " private E3() {}\n" + >+ " public E3(long l) {}\n" + >+ "}\n" + >+ "class E4 {\n" + >+ " @Deprecated\n" + >+ " @p.Annot\n" + >+ " private E4() {}\n" + >+ " public E4(long l) {}\n" + >+ "}\n", >+ "p/NonNull.java", >+ "package p;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "import java.lang.annotation.*;\n" + >+ "@Target({TYPE, METHOD,PARAMETER,CONSTRUCTOR})\n" + >+ "public @interface NonNull {\n" + >+ "}", >+ "p/Annot.java", >+ "package p;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "import java.lang.annotation.*;\n" + >+ "@Target({TYPE, METHOD,PARAMETER,LOCAL_VARIABLE, CONSTRUCTOR})\n" + >+ "public @interface Annot {\n" + >+ "}" >+ }, >+ null, customOptions, >+ "----------\n" + >+ "1. ERROR in Example.java (at line 10)\n" + >+ " private E1() {}\n" + >+ " ^^^^\n" + >+ "The constructor E1() is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in Example.java (at line 14)\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " ^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"null\")\n" + >+ "----------\n" + >+ "3. ERROR in Example.java (at line 15)\n" + >+ " private E2() {}\n" + >+ " ^^^^\n" + >+ "The constructor E2() is never used locally\n" + >+ "----------\n" + >+ "4. ERROR in Example.java (at line 20)\n" + >+ " private E3() {}\n" + >+ " ^^^^\n" + >+ "The constructor E3() is never used locally\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 >+// unused field >+public void testBug365437e() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_AnnotationBasedNullAnalysis, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "p.NonNull"); >+ this.runNegativeTest( >+ true, >+ new String[] { >+ "Example.java", >+ "class Example {\n" + >+ " @p.Annot\n" + >+ " private int Ex;\n" + >+ "}\n" + >+ "class E1 {\n" + >+ " @Deprecated\n" + >+ " private int E1;\n" + >+ "}\n" + >+ "class E2 {\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " private int E2;\n" + >+ "}\n" + >+ "class E3 {\n" + >+ " @p.NonNull\n" + >+ " private int E3;\n" + >+ "}\n" + >+ "class E4 {\n" + >+ " @Deprecated\n" + >+ " @p.Annot\n" + >+ " private int E4;\n" + >+ "}\n", >+ "p/NonNull.java", >+ "package p;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "import java.lang.annotation.*;\n" + >+ "@Target({TYPE, METHOD,PARAMETER,LOCAL_VARIABLE, FIELD})\n" + >+ "public @interface NonNull {\n" + >+ "}", >+ "p/Annot.java", >+ "package p;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "import java.lang.annotation.*;\n" + >+ "@Target({TYPE, METHOD,PARAMETER,LOCAL_VARIABLE, FIELD})\n" + >+ "public @interface Annot {\n" + >+ "}" >+ }, >+ null, customOptions, >+ "----------\n" + >+ "1. ERROR in Example.java (at line 7)\n" + >+ " private int E1;\n" + >+ " ^^\n" + >+ "The value of the field E1.E1 is not used\n" + >+ "----------\n" + >+ "2. WARNING in Example.java (at line 10)\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " ^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"null\")\n" + >+ "----------\n" + >+ "3. ERROR in Example.java (at line 11)\n" + >+ " private int E2;\n" + >+ " ^^\n" + >+ "The value of the field E2.E2 is not used\n" + >+ "----------\n" + >+ "4. ERROR in Example.java (at line 15)\n" + >+ " private int E3;\n" + >+ " ^^\n" + >+ "The value of the field E3.E3 is not used\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 >+// unused type >+public void testBug365437f() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_AnnotationBasedNullAnalysis, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "p.NonNull"); >+ this.runNegativeTest( >+ true, >+ new String[] { >+ "Example.java", >+ "class Example {\n" + >+ " @p.Annot\n" + >+ " private class Ex{}\n" + >+ "}\n" + >+ "class E1 {\n" + >+ " @Deprecated\n" + >+ " private class E11{}\n" + >+ "}\n" + >+ "class E2 {\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " private class E22{}\n" + >+ "}\n" + >+ "class E3 {\n" + >+ " @p.NonNull\n" + >+ " private class E33{}\n" + >+ "}\n" + >+ "class E4 {\n" + >+ " @Deprecated\n" + >+ " @p.Annot\n" + >+ " private class E44{}\n" + >+ "}\n", >+ "p/NonNull.java", >+ "package p;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "import java.lang.annotation.*;\n" + >+ "@Target({TYPE, METHOD,PARAMETER,LOCAL_VARIABLE})\n" + >+ "public @interface NonNull {\n" + >+ "}", >+ "p/Annot.java", >+ "package p;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "import java.lang.annotation.*;\n" + >+ "@Target({TYPE, METHOD,PARAMETER,LOCAL_VARIABLE, CONSTRUCTOR})\n" + >+ "public @interface Annot {\n" + >+ "}" >+ }, >+ null, customOptions, >+ "----------\n" + >+ "1. ERROR in Example.java (at line 7)\n" + >+ " private class E11{}\n" + >+ " ^^^\n" + >+ "The type E1.E11 is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in Example.java (at line 10)\n" + >+ " @SuppressWarnings(\"null\")\n" + >+ " ^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"null\")\n" + >+ "----------\n" + >+ "3. ERROR in Example.java (at line 11)\n" + >+ " private class E22{}\n" + >+ " ^^^\n" + >+ "The type E2.E22 is never used locally\n" + >+ "----------\n" + >+ "4. ERROR in Example.java (at line 15)\n" + >+ " private class E33{}\n" + >+ " ^^^\n" + >+ "The type E3.E33 is never used locally\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java >index bc76ad7..68ed9eb 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -167,12 +167,6 @@ > break; > case TypeIds.T_JavaLangInvokeMethodHandlePolymorphicSignature : > tagBits |= TagBits.AnnotationPolymorphicSignature; >- break; >- case TypeIds.T_JavaxAnnotationPostConstruct : >- tagBits |= TagBits.AnnotationPostConstruct; >- break; >- case TypeIds.T_JavaxAnnotationPreDestroy : >- tagBits |= TagBits.AnnotationPreDestroy; > break; > case TypeIds.T_ConfiguredAnnotationNullable : > tagBits |= TagBits.AnnotationNullable; >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java >index 3357d7d..d81ec1c 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java >@@ -303,10 +303,6 @@ > currentOffset += 2; > return readTargetValue(currentOffset); > } >- if (CharOperation.equals(typeName, ConstantPool.JAVAX_ANNOTATION_PREDESTROY)) { >- this.standardAnnotationTagBits |= TagBits.AnnotationPreDestroy; >- return currentOffset; >- } > break; > case 32: > if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_RETENTION)) { >@@ -315,10 +311,6 @@ > } > if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_INHERITED)) { > this.standardAnnotationTagBits |= TagBits.AnnotationInherited; >- return currentOffset; >- } >- if (CharOperation.equals(typeName, ConstantPool.JAVAX_ANNOTATION_POSTCONSTRUCT)) { >- this.standardAnnotationTagBits |= TagBits.AnnotationPostConstruct; > return currentOffset; > } > break; >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java >index c875c9b..c449385 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -248,8 +248,6 @@ > public static final char[] JAVA_LANG_SAFEVARARGS = "Ljava/lang/SafeVarargs;".toCharArray(); //$NON-NLS-1$ > // java 7 java.lang.invoke.MethodHandle.invokeExact(..)/invokeGeneric(..) > public static final char[] JAVA_LANG_INVOKE_METHODHANDLE_POLYMORPHICSIGNATURE = "Ljava/lang/invoke/MethodHandle$PolymorphicSignature;".toCharArray(); //$NON-NLS-1$ >- public static final char[] JAVAX_ANNOTATION_POSTCONSTRUCT = "Ljavax/annotation/PostConstruct;".toCharArray(); //$NON-NLS-1$ >- public static final char[] JAVAX_ANNOTATION_PREDESTROY = "Ljavax/annotation/PreDestroy;".toCharArray(); //$NON-NLS-1$ > > public static final char[] HashCode = "hashCode".toCharArray(); //$NON-NLS-1$ > public static final char[] HashCodeSignature = "()I".toCharArray(); //$NON-NLS-1$; >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 c88c4a1..038c5ad 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 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -54,11 +54,10 @@ > count++; > if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0) > count++; >- if ((annotationTagBits & TagBits.AnnotationPostConstruct) != 0) >- count++; >- if ((annotationTagBits & TagBits.AnnotationPreDestroy) != 0) >- count++; >- // count must be different from 0 >+ if (count == 0) { >+ // this is possible if bits were set for null annotations >+ return recordedAnnotations; >+ } > > int index = recordedAnnotations.length; > AnnotationBinding[] result = new AnnotationBinding[index + count]; >@@ -81,10 +80,6 @@ > result[index++] = buildMarkerAnnotationForMemberType(TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE, env); > if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0) > result[index++] = buildMarkerAnnotation(TypeConstants.JAVA_LANG_SAFEVARARGS, env); >- if ((annotationTagBits & TagBits.AnnotationPostConstruct) != 0) >- result[index++] = buildMarkerAnnotation(TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT, env); >- if ((annotationTagBits & TagBits.AnnotationPreDestroy) != 0) >- result[index++] = buildMarkerAnnotation(TypeConstants.JAVAX_ANNOTATION_PREDESTROY, env); > return result; > } > >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >index 75de854..8e57afb 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -380,8 +380,7 @@ > switch (this.compoundName.length) { > > case 3 : >- if (!CharOperation.equals(TypeConstants.JAVA, this.compoundName[0]) >- && !CharOperation.equals(TypeConstants.JAVAX, this.compoundName[0])) >+ if (!CharOperation.equals(TypeConstants.JAVA, this.compoundName[0])) > return; > > char[] packageName = this.compoundName[1]; >@@ -389,19 +388,6 @@ > char[] typeName = this.compoundName[2]; > if (typeName.length == 0) return; // just to be safe > // remaining types MUST be in java.*.* >- if (CharOperation.equals(TypeConstants.JAVAX, this.compoundName[0])) { >- if (CharOperation.equals(TypeConstants.ANNOTATION, this.compoundName[1])) { >- switch (typeName[0]) { >- case 'P' : >- if (CharOperation.equals(typeName, TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT[2])) >- this.id = TypeIds.T_JavaxAnnotationPostConstruct; >- if (CharOperation.equals(typeName, TypeConstants.JAVAX_ANNOTATION_PREDESTROY[2])) >- this.id = TypeIds.T_JavaxAnnotationPreDestroy; >- return; >- } >- } >- return; >- } > if (!CharOperation.equals(TypeConstants.LANG, this.compoundName[1])) { > switch (packageName[0]) { > case 'i' : >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java >index 9ba6da0..21b1c11 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -129,10 +129,6 @@ > long AnnotationSafeVarargs = ASTNode.Bit52L; > /** @since 3.7 - java 7 MethodHandle.invokeExact(..)/invokeGeneric(..)*/ > long AnnotationPolymorphicSignature = ASTNode.Bit53L; >- /** @since 3.8 */ >- long AnnotationPreDestroy = ASTNode.Bit54L; >- /** @since 3.8 */ >- long AnnotationPostConstruct = ASTNode.Bit55L; > /** @since 3.8 null annotation for MethodBinding or LocalVariableBinding (argument): */ > long AnnotationNullable = ASTNode.Bit56L; > /** @since 3.8 null annotation for MethodBinding or LocalVariableBinding (argument): */ >@@ -152,8 +148,6 @@ > | AnnotationSuppressWarnings > | AnnotationSafeVarargs > | AnnotationPolymorphicSignature >- | AnnotationPostConstruct >- | AnnotationPreDestroy > | AnnotationNullable > | AnnotationNonNull > | AnnotationNonNullByDefault >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java >index 0bbef47..7098d37 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -177,18 +177,6 @@ > char[] SYNTHETIC_ACCESS_METHOD_PREFIX = "access$".toCharArray(); //$NON-NLS-1$ > char[] SYNTHETIC_ENUM_CONSTANT_INITIALIZATION_METHOD_PREFIX = " enum constant initialization$".toCharArray(); //$NON-NLS-1$ > char[] SYNTHETIC_STATIC_FACTORY = "<factory>".toCharArray(); //$NON-NLS-1$ >- char[][] JAVAX_ANNOTATION_POSTCONSTRUCT = >- new char[][] { >- JAVAX, >- ANNOTATION, >- "PostConstruct".toCharArray() //$NON-NLS-1$ >- }; >- char[][] JAVAX_ANNOTATION_PREDESTROY = >- new char[][] { >- JAVAX, >- ANNOTATION, >- "PreDestroy".toCharArray() //$NON-NLS-1$ >- }; > > // synthetic package-info name > public static final char[] PACKAGE_INFO_NAME = "package-info".toCharArray(); //$NON-NLS-1$ >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java >index 7fff434..5156a44 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -100,11 +100,6 @@ > > // java 7 java.lang.AutoCloseable > final int T_JavaLangAutoCloseable = 62; >- >- // new in 3.8 >- final int T_JavaxAnnotationPostConstruct = 63; >- >- final int T_JavaxAnnotationPreDestroy = 64; > > // new in 3.8 for null annotations: > final int T_ConfiguredAnnotationNullable = 65; >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >index 9b83933..2e50777 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -7592,7 +7592,9 @@ > > int severity = computeSeverity(IProblem.UnusedPrivateConstructor); > if (severity == ProblemSeverities.Ignore) return; >- >+ >+ if (excludeDueToAnnotation(constructorDecl.annotations)) return; >+ > MethodBinding constructor = constructorDecl.binding; > this.handle( > IProblem.UnusedPrivateConstructor, >@@ -7638,6 +7640,7 @@ > } > } > } >+ if (excludeDueToAnnotation(fieldDecl.annotations)) return; > this.handle( > IProblem.UnusedPrivateField, > new String[] { >@@ -7691,10 +7694,8 @@ > && CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) { > return; > } >- if ((method.tagBits & (TagBits.AnnotationPostConstruct | TagBits.AnnotationPreDestroy)) != 0) { >- // PostConstruct and PreDestroy method are ignored >- return; >- } >+ if (excludeDueToAnnotation(methodDecl.annotations)) return; >+ > this.handle( > IProblem.UnusedPrivateMethod, > new String[] { >@@ -7711,10 +7712,43 @@ > methodDecl.sourceStart, > methodDecl.sourceEnd); > } >+ >+/** >+ * Returns true if a private member should not be warned as unused if >+ * annotated with a non-standard annotation >+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 >+ */ >+private boolean excludeDueToAnnotation(Annotation[] annotations) { >+ int annotationsLen = 0; >+ if (annotations != null) { >+ annotationsLen = annotations.length; >+ } else { >+ return false; >+ } >+ if (annotationsLen == 0) return false; >+ for (int i = 0; i < annotationsLen; i++) { >+ TypeBinding resolvedType = annotations[i].resolvedType; >+ if (resolvedType != null) { >+ switch (resolvedType.id) { >+ case TypeIds.T_JavaLangSuppressWarnings: >+ case TypeIds.T_JavaLangDeprecated: >+ case TypeIds.T_JavaLangSafeVarargs: >+ case TypeIds.T_ConfiguredAnnotationNonNull: >+ case TypeIds.T_ConfiguredAnnotationNullable: >+ case TypeIds.T_ConfiguredAnnotationNonNullByDefault: >+ break; >+ default: >+ // non-standard annotation found, don't warn >+ return true; >+ } >+ } >+ } >+ return false; >+} > public void unusedPrivateType(TypeDeclaration typeDecl) { > int severity = computeSeverity(IProblem.UnusedPrivateType); > if (severity == ProblemSeverities.Ignore) return; >- >+ if (excludeDueToAnnotation(typeDecl.annotations)) return; > ReferenceBinding type = typeDecl.binding; > this.handle( > IProblem.UnusedPrivateType, >diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java >index 94e6db1..3f6d742 100644 >--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java >+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -86,12 +86,6 @@ > } > if ((tagBits & TagBits.AnnotationSafeVarargs) != 0) { > annotations.add(getAnnotation(TypeConstants.JAVA_LANG_SAFEVARARGS)); >- } >- if ((tagBits & TagBits.AnnotationPostConstruct) != 0) { >- annotations.add(getAnnotation(TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT)); >- } >- if ((tagBits & TagBits.AnnotationPreDestroy) != 0) { >- annotations.add(getAnnotation(TypeConstants.JAVAX_ANNOTATION_PREDESTROY)); > } > // note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries > return (IAnnotation[]) annotations.toArray(new IAnnotation[annotations.size()]); >diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java >index bcf7ceb..e1714a0 100644 >--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java >+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -107,12 +107,6 @@ > } > if ((tagBits & TagBits.AnnotationSafeVarargs) != 0) { > generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_SAFEVARARGS, Annotation.NO_MEMBER_VALUE_PAIRS, newElements); >- } >- if ((tagBits & TagBits.AnnotationPostConstruct) != 0) { >- generateStandardAnnotation(javaElement, TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT, Annotation.NO_MEMBER_VALUE_PAIRS, newElements); >- } >- if ((tagBits & TagBits.AnnotationPreDestroy) != 0) { >- generateStandardAnnotation(javaElement, TypeConstants.JAVAX_ANNOTATION_PREDESTROY, Annotation.NO_MEMBER_VALUE_PAIRS, newElements); > } > // note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries > } >diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java >index c242fb5..f752c34 100644 >--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java >+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -46,6 +46,9 @@ > super(document); > } > private void addBinaryStandardAnnotations(long annotationTagBits) { >+ if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) { >+ return; >+ } > if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) { > char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET; > addAnnotationTypeReference(compoundName[compoundName.length-1]); >@@ -83,14 +86,6 @@ > if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) { > char[][] compoundName = > TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE; >- addAnnotationTypeReference(compoundName[compoundName.length-1]); >- } >- if ((annotationTagBits & TagBits.AnnotationPostConstruct) != 0) { >- char[][] compoundName = TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT; >- addAnnotationTypeReference(compoundName[compoundName.length-1]); >- } >- if ((annotationTagBits & TagBits.AnnotationPreDestroy) != 0) { >- char[][] compoundName = TypeConstants.JAVAX_ANNOTATION_PREDESTROY; > addAnnotationTypeReference(compoundName[compoundName.length-1]); > } > } >diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java >index 37608aa..1c86721 100644 >--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java >+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -90,6 +90,9 @@ > return true; > } > private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) { >+ if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) { >+ return false; >+ } > if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) { > char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET; > if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern) || >@@ -142,18 +145,6 @@ > } > if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) { > char[][] compoundName = TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE; >- if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) { >- return true; >- } >- } >- if ((annotationTagBits & TagBits.AnnotationPostConstruct) != 0) { >- char[][] compoundName = TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT; >- if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) { >- return true; >- } >- } >- if ((annotationTagBits & TagBits.AnnotationPreDestroy) != 0) { >- char[][] compoundName = TypeConstants.JAVAX_ANNOTATION_PREDESTROY; > if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) { > return true; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 365437
:
207974
|
209012
|
209200
| 209250