changeset 505:85242c273d31

6929645: Address various findbugs warnings in langtools Reviewed-by: jjg
author darcy
date Thu, 25 Feb 2010 11:04:11 -0800
parents 87eb6edd4f21
children dbcba45123cd
files src/share/classes/com/sun/tools/apt/comp/Apt.java src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
diffstat 5 files changed, 33 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
                 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 @@
      * 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 @@
      * 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 @@
     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;
 
 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 @@
      * 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 @@
         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 @@
      * 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 @@
         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 @@
             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 @@
                                      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 @@
         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();