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 202153 Details for
Bug 346529
Don't show "The method * from the type * is never used locally" warning for private methods annotated with standard annotations like @PostConstruct
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
patch_346529.txt (text/plain), 17.58 KB, created by
Olivier Thomann
on 2011-08-25 09:59:14 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2011-08-25 09:59:14 EDT
Size:
17.58 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java,v >retrieving revision 1.71 >diff -u -r1.71 Annotation.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 28 Jul 2011 17:07:01 -0000 1.71 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 25 Aug 2011 13:58:33 -0000 >@@ -167,6 +167,12 @@ > case TypeIds.T_JavaLangInvokeMethodHandlePolymorphicSignature : > tagBits |= TagBits.AnnotationPolymorphicSignature; > break; >+ case TypeIds.T_JavaxAnnotationPostConstruct : >+ tagBits |= TagBits.AnnotationPostConstruct; >+ break; >+ case TypeIds.T_JavaxAnnotationPreDestroy : >+ tagBits |= TagBits.AnnotationPreDestroy; >+ break; > } > return tagBits; > } >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java,v >retrieving revision 1.9 >diff -u -r1.9 AnnotationInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java 28 Jul 2011 17:07:46 -0000 1.9 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java 25 Aug 2011 13:58:33 -0000 >@@ -303,6 +303,10 @@ > 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)) { >@@ -313,6 +317,10 @@ > this.standardAnnotationTagBits |= TagBits.AnnotationInherited; > return currentOffset; > } >+ if (CharOperation.equals(typeName, ConstantPool.JAVAX_ANNOTATION_POSTCONSTRUCT)) { >+ this.standardAnnotationTagBits |= TagBits.AnnotationPostConstruct; >+ return currentOffset; >+ } > break; > case 33: > if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_DOCUMENTED)) { >Index: compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java,v >retrieving revision 1.62 >diff -u -r1.62 ConstantPool.java >--- compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java 28 Jul 2011 17:07:42 -0000 1.62 >+++ compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java 25 Aug 2011 13:58:33 -0000 >@@ -248,6 +248,8 @@ > 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$; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java,v >retrieving revision 1.16 >diff -u -r1.16 AnnotationBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java 28 Jul 2011 17:07:22 -0000 1.16 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java 25 Aug 2011 13:58:33 -0000 >@@ -32,6 +32,9 @@ > public static AnnotationBinding[] addStandardAnnotations(AnnotationBinding[] recordedAnnotations, long annotationTagBits, LookupEnvironment env) { > // NOTE: expect annotations to be requested just once so there is no need to store the standard annotations > // and all of the standard annotations created by this method are fully resolved since the sender is expected to use them immediately >+ if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) { >+ return recordedAnnotations; >+ } > int count = 0; > if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) > count++; >@@ -51,8 +54,11 @@ > count++; > if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0) > count++; >- if (count == 0) >- return recordedAnnotations; >+ if ((annotationTagBits & TagBits.AnnotationPostConstruct) != 0) >+ count++; >+ if ((annotationTagBits & TagBits.AnnotationPreDestroy) != 0) >+ count++; >+ // count must be different from 0 > > int index = recordedAnnotations.length; > AnnotationBinding[] result = new AnnotationBinding[index + count]; >@@ -75,6 +81,10 @@ > 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; > } > >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java,v >retrieving revision 1.143 >diff -u -r1.143 ReferenceBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 28 Jul 2011 17:07:23 -0000 1.143 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 25 Aug 2011 13:58:33 -0000 >@@ -365,14 +365,28 @@ > switch (this.compoundName.length) { > > case 3 : >- if (!CharOperation.equals(TypeConstants.JAVA, this.compoundName[0])) >+ if (!CharOperation.equals(TypeConstants.JAVA, this.compoundName[0]) >+ && !CharOperation.equals(TypeConstants.JAVAX, this.compoundName[0])) > return; >- >+ > char[] packageName = this.compoundName[1]; > if (packageName.length == 0) return; // just to be safe > 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' : >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java,v >retrieving revision 1.49 >diff -u -r1.49 TagBits.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java 28 Jul 2011 17:07:23 -0000 1.49 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java 25 Aug 2011 13:58:33 -0000 >@@ -128,8 +128,13 @@ > 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; > >- long AllStandardAnnotationsMask = AnnotationTargetMASK >+ long AllStandardAnnotationsMask = >+ AnnotationTargetMASK > | AnnotationRetentionMASK > | AnnotationDeprecated > | AnnotationDocumented >@@ -137,10 +142,12 @@ > | AnnotationOverride > | AnnotationSuppressWarnings > | AnnotationSafeVarargs >- | AnnotationPolymorphicSignature; >+ | AnnotationPolymorphicSignature >+ | AnnotationPostConstruct >+ | AnnotationPreDestroy; > >- long DefaultValueResolved = ASTNode.Bit54L; >+ long DefaultValueResolved = ASTNode.Bit56L; > > // set when type contains non-private constructor(s) >- long HasNonPrivateConstructor = ASTNode.Bit55L; >+ long HasNonPrivateConstructor = ASTNode.Bit57L; > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java,v >retrieving revision 1.52 >diff -u -r1.52 TypeConstants.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 28 Jul 2011 17:07:23 -0000 1.52 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 25 Aug 2011 13:58:33 -0000 >@@ -14,6 +14,7 @@ > public interface TypeConstants { > > char[] JAVA = "java".toCharArray(); //$NON-NLS-1$ >+ char[] JAVAX = "javax".toCharArray(); //$NON-NLS-1$ > char[] LANG = "lang".toCharArray(); //$NON-NLS-1$ > char[] IO = "io".toCharArray(); //$NON-NLS-1$ > char[] UTIL = "util".toCharArray(); //$NON-NLS-1$ >@@ -129,7 +130,7 @@ > char[][] JAVA_IO_OBJECTINPUTSTREAM = new char[][] { JAVA, IO, "ObjectInputStream".toCharArray()}; //$NON-NLS-1$ > // javax.rmi.CORBA.Stub > char[][] JAVAX_RMI_CORBA_STUB = new char[][] { >- "javax".toCharArray(), //$NON-NLS-1$ >+ JAVAX, > "rmi".toCharArray(), //$NON-NLS-1$ > "CORBA".toCharArray(), //$NON-NLS-1$ > "Stub".toCharArray(), //$NON-NLS-1$ >@@ -173,6 +174,18 @@ > 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$ >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java,v >retrieving revision 1.39 >diff -u -r1.39 TypeIds.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java 1 Aug 2011 05:37:22 -0000 1.39 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java 25 Aug 2011 13:58:33 -0000 >@@ -97,6 +97,11 @@ > // java 7 java.lang.AutoCloseable > final int T_JavaLangAutoCloseable = 62; > >+ // new in 3.8 >+ final int T_JavaxAnnotationPostConstruct = 63; >+ >+ final int T_JavaxAnnotationPreDestroy = 64; >+ > final int NoId = Integer.MAX_VALUE; > > public static final int IMPLICIT_CONVERSION_MASK = 0xFF; >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.439 >diff -u -r1.439 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 23 Aug 2011 06:03:55 -0000 1.439 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 25 Aug 2011 13:58:34 -0000 >@@ -7596,6 +7596,10 @@ > && CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) { > return; > } >+ if ((method.tagBits & (TagBits.AnnotationPostConstruct | TagBits.AnnotationPreDestroy)) != 0) { >+ // PostConstruct and PreDestroy method are ignored >+ return; >+ } > this.handle( > IProblem.UnusedPrivateMethod, > new String[] { >Index: model/org/eclipse/jdt/internal/core/BinaryMember.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java,v >retrieving revision 1.38 >diff -u -r1.38 BinaryMember.java >--- model/org/eclipse/jdt/internal/core/BinaryMember.java 28 Jul 2011 17:07:07 -0000 1.38 >+++ model/org/eclipse/jdt/internal/core/BinaryMember.java 25 Aug 2011 13:58:34 -0000 >@@ -87,6 +87,12 @@ > 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()]); > } >Index: model/org/eclipse/jdt/internal/core/ClassFileInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java,v >retrieving revision 1.51 >diff -u -r1.51 ClassFileInfo.java >--- model/org/eclipse/jdt/internal/core/ClassFileInfo.java 28 Jul 2011 17:07:07 -0000 1.51 >+++ model/org/eclipse/jdt/internal/core/ClassFileInfo.java 25 Aug 2011 13:58:34 -0000 >@@ -108,6 +108,12 @@ > 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 > } > >Index: search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java,v >retrieving revision 1.72 >diff -u -r1.72 BinaryIndexer.java >--- search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java 28 Jul 2011 17:07:36 -0000 1.72 >+++ search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java 25 Aug 2011 13:58:34 -0000 >@@ -85,6 +85,14 @@ > 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]); >+ } > } > private void addBinaryTargetAnnotation(long bits) { > char[][] compoundName = null; >Index: search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java,v >retrieving revision 1.45 >diff -u -r1.45 ClassFileMatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java 28 Jul 2011 17:07:23 -0000 1.45 >+++ search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java 25 Aug 2011 13:58:34 -0000 >@@ -146,6 +146,18 @@ > 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; >+ } >+ } > return false; > } > private boolean checkTypeName(char[] simpleName, char[] qualification, char[] fullyQualifiedTypeName, boolean isCaseSensitive, boolean isCamelCase) {
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 346529
: 202153