JDK-6929645 : Address various findbugs warnings in langtools
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-02-25
  • Updated: 2014-09-29
  • Resolved: 2012-01-17
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 :  
Relates :  
Relates :  
Description
Findbugs flags various issues in the langtools repository; at least some of these issues should be addressed.

Comments
SUGGESTED FIX # HG changeset patch # User darcy # Date 1267124651 28800 # Node ID 85242c273d31f5b5f95bc26ee637b1e9055768cc # Parent 87eb6edd4f218d616c4f1a48b5afce40c148f974 6929645: Address various findbugs warnings in langtools Reviewed-by: jjg --- a/src/share/classes/com/sun/tools/apt/comp/Apt.java Thu Feb 25 09:42:35 2010 -0800 +++ b/src/share/classes/com/sun/tools/apt/comp/Apt.java Thu Feb 25 11:04:11 2010 -0800 @@ -457,8 +457,10 @@ public class Apt extends ListBuffer<Env< throw new UsageMessageNeededException(); try { - for(AnnotationProcessorFactory apFactory: factoryToAnnotation.keySet()) { - AnnotationProcessor processor = apFactory.getProcessorFor(factoryToAnnotation.get(apFactory), + for(Map.Entry<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> entry : + factoryToAnnotation.entrySet()) { + AnnotationProcessorFactory apFactory = entry.getKey(); + AnnotationProcessor processor = apFactory.getProcessorFor(entry.getValue(), trivAPE); if (processor != null) processors.add(processor); --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java Thu Feb 25 09:42:35 2010 -0800 +++ b/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java Thu Feb 25 11:04:11 2010 -0800 @@ -270,7 +270,7 @@ class AnnotationProxyMaker { * The toString, hashCode, and equals methods foward to the underlying * type. */ - private static class MirroredTypeExceptionProxy extends ExceptionProxy { + private static final class MirroredTypeExceptionProxy extends ExceptionProxy { private static final long serialVersionUID = 6662035281599933545L; private MirroredTypeException ex; @@ -312,7 +312,7 @@ class AnnotationProxyMaker { * The toString, hashCode, and equals methods foward to the underlying * types. */ - private static class MirroredTypesExceptionProxy extends ExceptionProxy { + private static final class MirroredTypesExceptionProxy extends ExceptionProxy { private static final long serialVersionUID = -6670822532616693951L; private MirroredTypesException ex; --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java Thu Feb 25 09:42:35 2010 -0800 +++ b/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java Thu Feb 25 11:04:11 2010 -0800 @@ -58,7 +58,7 @@ public abstract class DeclarationImpl im protected final AptEnv env; public final Symbol sym; - protected static DeclarationFilter identityFilter = + protected static final DeclarationFilter identityFilter = new DeclarationFilter(); --- a/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java Thu Feb 25 09:42:35 2010 -0800 +++ b/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java Thu Feb 25 11:04:11 2010 -0800 @@ -26,6 +26,8 @@ package com.sun.tools.javac.model; package com.sun.tools.javac.model; import com.sun.tools.javac.util.*; +import java.io.ObjectInputStream; +import java.io.IOException; import java.lang.annotation.*; import java.lang.reflect.Array; import java.lang.reflect.Method; @@ -268,10 +270,10 @@ public class AnnotationProxyMaker { * The toString, hashCode, and equals methods foward to the underlying * type. */ - private static class MirroredTypeExceptionProxy extends ExceptionProxy { + private static final class MirroredTypeExceptionProxy extends ExceptionProxy { static final long serialVersionUID = 269; - private transient final TypeMirror type; + private transient TypeMirror type; private final String typeString; MirroredTypeExceptionProxy(TypeMirror t) { @@ -296,6 +298,13 @@ public class AnnotationProxyMaker { protected RuntimeException generateException() { return new MirroredTypeException(type); } + + // Explicitly set all transient fields. + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + s.defaultReadObject(); + type = null; + } } @@ -304,10 +313,10 @@ public class AnnotationProxyMaker { * The toString, hashCode, and equals methods foward to the underlying * types. */ - private static class MirroredTypesExceptionProxy extends ExceptionProxy { + private static final class MirroredTypesExceptionProxy extends ExceptionProxy { static final long serialVersionUID = 269; - private transient final List<TypeMirror> types; + private transient List<TypeMirror> types; private final String typeStrings; MirroredTypesExceptionProxy(List<TypeMirror> ts) { @@ -333,5 +342,12 @@ public class AnnotationProxyMaker { protected RuntimeException generateException() { return new MirroredTypesException(types); } + + // Explicitly set all transient fields. + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + s.defaultReadObject(); + types = null; + } } } --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu Feb 25 09:42:35 2010 -0800 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu Feb 25 11:04:11 2010 -0800 @@ -690,10 +690,12 @@ public class JavacProcessingEnvironment ProcessorState ps = psi.next(); Set<String> matchedNames = new HashSet<String>(); Set<TypeElement> typeElements = new LinkedHashSet<TypeElement>(); - for (String unmatchedAnnotationName : unmatchedAnnotations.keySet()) { + + for (Map.Entry<String, TypeElement> entry: unmatchedAnnotations.entrySet()) { + String unmatchedAnnotationName = entry.getKey(); if (ps.annotationSupported(unmatchedAnnotationName) ) { matchedNames.add(unmatchedAnnotationName); - TypeElement te = unmatchedAnnotations.get(unmatchedAnnotationName); + TypeElement te = entry.getValue(); if (te != null) typeElements.add(te); } @@ -790,7 +792,7 @@ public class JavacProcessingEnvironment List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols, Iterable<? extends PackageSymbol> pckSymbols) - throws IOException { + throws IOException { log = Log.instance(context); // Writer for -XprintRounds and -XprintProcessorInfo data @@ -1218,7 +1220,7 @@ public class JavacProcessingEnvironment return false; } - private class AnnotationCollector extends TreeScanner { + private static class AnnotationCollector extends TreeScanner { List<JCTree> path = List.nil(); static final boolean verbose = false; List<JCAnnotation> annotations = List.nil();
25-02-2010

PUBLIC COMMENTS See http://hg.openjdk.java.net/jdk7/tl/langtools/rev/85242c273d31
25-02-2010

EVALUATION Yes.
25-02-2010