JDK-6931130 : Remove unused AnnotationCollector code from JavacProcessingEnvironment
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-03-02
  • Updated: 2011-07-25
  • Resolved: 2011-07-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b86Fixed
Related Reports
Relates :  
Description
Findbugs has noticed that code associated with AnnotationCollector in  JavacProcessingEnvironment.java is unused; the unused code should be removed.

Comments
SUGGESTED FIX # HG changeset patch # User darcy # Date 1267567607 28800 # Node ID 7c23bbbe0dbdaa987a4217043f81ec7d346e5955 # Parent 7b69c7083a97cc9536a1a260509f04847ef5fa7a 6931130: Remove unused AnnotationCollector code from JavacProcessingEnvironment Reviewed-by: jjg --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Fri Feb 26 15:30:35 2010 -0800 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Mar 02 14:06:47 2010 -0800 @@ -799,9 +799,6 @@ public class JavacProcessingEnvironment PrintWriter xout = context.get(Log.outKey); TaskListener taskListener = context.get(TaskListener.class); - - AnnotationCollector collector = new AnnotationCollector(); - JavaCompiler compiler = JavaCompiler.instance(context); compiler.todo.clear(); // free the compiler's resources @@ -1220,45 +1217,6 @@ public class JavacProcessingEnvironment return false; } - private static class AnnotationCollector extends TreeScanner { - List<JCTree> path = List.nil(); - static final boolean verbose = false; - List<JCAnnotation> annotations = List.nil(); - - public List<JCAnnotation> findAnnotations(List<? extends JCTree> nodes) { - annotations = List.nil(); - scan(nodes); - List<JCAnnotation> found = annotations; - annotations = List.nil(); - return found.reverse(); - } - - public void scan(JCTree node) { - if (node == null) - return; - Symbol sym = TreeInfo.symbolFor(node); - if (sym != null) - path = path.prepend(node); - super.scan(node); - if (sym != null) - path = path.tail; - } - - public void visitAnnotation(JCAnnotation node) { - annotations = annotations.prepend(node); - if (verbose) { - StringBuilder sb = new StringBuilder(); - for (JCTree tree : path.reverse()) { - System.err.print(sb); - System.err.println(TreeInfo.symbolFor(tree)); - sb.append(" "); - } - System.err.print(sb); - System.err.println(node); - } - } - } - private static <T extends JCTree> List<T> cleanTrees(List<T> nodes) { for (T node : nodes) treeCleaner.scan(node);
02-03-2010

PUBLIC COMMENTS See http://hg.openjdk.java.net/jdk7/tl/langtools/rev/7c23bbbe0dbd
02-03-2010

EVALUATION Yes.
02-03-2010