提交 72c1129d 编写于 作者: D darcy

6929645: Address various findbugs warnings in langtools

Reviewed-by: jjg
上级 0a737416
...@@ -457,8 +457,10 @@ public class Apt extends ListBuffer<Env<AttrContext>> { ...@@ -457,8 +457,10 @@ public class Apt extends ListBuffer<Env<AttrContext>> {
throw new UsageMessageNeededException(); throw new UsageMessageNeededException();
try { try {
for(AnnotationProcessorFactory apFactory: factoryToAnnotation.keySet()) { for(Map.Entry<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> entry :
AnnotationProcessor processor = apFactory.getProcessorFor(factoryToAnnotation.get(apFactory), factoryToAnnotation.entrySet()) {
AnnotationProcessorFactory apFactory = entry.getKey();
AnnotationProcessor processor = apFactory.getProcessorFor(entry.getValue(),
trivAPE); trivAPE);
if (processor != null) if (processor != null)
processors.add(processor); processors.add(processor);
......
...@@ -270,7 +270,7 @@ class AnnotationProxyMaker { ...@@ -270,7 +270,7 @@ class AnnotationProxyMaker {
* The toString, hashCode, and equals methods foward to the underlying * The toString, hashCode, and equals methods foward to the underlying
* type. * type.
*/ */
private static class MirroredTypeExceptionProxy extends ExceptionProxy { private static final class MirroredTypeExceptionProxy extends ExceptionProxy {
private static final long serialVersionUID = 6662035281599933545L; private static final long serialVersionUID = 6662035281599933545L;
private MirroredTypeException ex; private MirroredTypeException ex;
...@@ -312,7 +312,7 @@ class AnnotationProxyMaker { ...@@ -312,7 +312,7 @@ class AnnotationProxyMaker {
* The toString, hashCode, and equals methods foward to the underlying * The toString, hashCode, and equals methods foward to the underlying
* types. * types.
*/ */
private static class MirroredTypesExceptionProxy extends ExceptionProxy { private static final class MirroredTypesExceptionProxy extends ExceptionProxy {
private static final long serialVersionUID = -6670822532616693951L; private static final long serialVersionUID = -6670822532616693951L;
private MirroredTypesException ex; private MirroredTypesException ex;
......
...@@ -58,7 +58,7 @@ public abstract class DeclarationImpl implements Declaration { ...@@ -58,7 +58,7 @@ public abstract class DeclarationImpl implements Declaration {
protected final AptEnv env; protected final AptEnv env;
public final Symbol sym; public final Symbol sym;
protected static DeclarationFilter identityFilter = protected static final DeclarationFilter identityFilter =
new DeclarationFilter(); new DeclarationFilter();
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
package com.sun.tools.javac.model; package com.sun.tools.javac.model;
import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.*;
import java.io.ObjectInputStream;
import java.io.IOException;
import java.lang.annotation.*; import java.lang.annotation.*;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -268,10 +270,10 @@ public class AnnotationProxyMaker { ...@@ -268,10 +270,10 @@ public class AnnotationProxyMaker {
* The toString, hashCode, and equals methods foward to the underlying * The toString, hashCode, and equals methods foward to the underlying
* type. * type.
*/ */
private static class MirroredTypeExceptionProxy extends ExceptionProxy { private static final class MirroredTypeExceptionProxy extends ExceptionProxy {
static final long serialVersionUID = 269; static final long serialVersionUID = 269;
private transient final TypeMirror type; private transient TypeMirror type;
private final String typeString; private final String typeString;
MirroredTypeExceptionProxy(TypeMirror t) { MirroredTypeExceptionProxy(TypeMirror t) {
...@@ -296,6 +298,13 @@ public class AnnotationProxyMaker { ...@@ -296,6 +298,13 @@ public class AnnotationProxyMaker {
protected RuntimeException generateException() { protected RuntimeException generateException() {
return new MirroredTypeException(type); 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 { ...@@ -304,10 +313,10 @@ public class AnnotationProxyMaker {
* The toString, hashCode, and equals methods foward to the underlying * The toString, hashCode, and equals methods foward to the underlying
* types. * types.
*/ */
private static class MirroredTypesExceptionProxy extends ExceptionProxy { private static final class MirroredTypesExceptionProxy extends ExceptionProxy {
static final long serialVersionUID = 269; static final long serialVersionUID = 269;
private transient final List<TypeMirror> types; private transient List<TypeMirror> types;
private final String typeStrings; private final String typeStrings;
MirroredTypesExceptionProxy(List<TypeMirror> ts) { MirroredTypesExceptionProxy(List<TypeMirror> ts) {
...@@ -333,5 +342,12 @@ public class AnnotationProxyMaker { ...@@ -333,5 +342,12 @@ public class AnnotationProxyMaker {
protected RuntimeException generateException() { protected RuntimeException generateException() {
return new MirroredTypesException(types); return new MirroredTypesException(types);
} }
// Explicitly set all transient fields.
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
types = null;
}
} }
} }
...@@ -690,10 +690,12 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ...@@ -690,10 +690,12 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
ProcessorState ps = psi.next(); ProcessorState ps = psi.next();
Set<String> matchedNames = new HashSet<String>(); Set<String> matchedNames = new HashSet<String>();
Set<TypeElement> typeElements = new LinkedHashSet<TypeElement>(); 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) ) { if (ps.annotationSupported(unmatchedAnnotationName) ) {
matchedNames.add(unmatchedAnnotationName); matchedNames.add(unmatchedAnnotationName);
TypeElement te = unmatchedAnnotations.get(unmatchedAnnotationName); TypeElement te = entry.getValue();
if (te != null) if (te != null)
typeElements.add(te); typeElements.add(te);
} }
...@@ -790,7 +792,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ...@@ -790,7 +792,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
List<JCCompilationUnit> roots, List<JCCompilationUnit> roots,
List<ClassSymbol> classSymbols, List<ClassSymbol> classSymbols,
Iterable<? extends PackageSymbol> pckSymbols) Iterable<? extends PackageSymbol> pckSymbols)
throws IOException { throws IOException {
log = Log.instance(context); log = Log.instance(context);
// Writer for -XprintRounds and -XprintProcessorInfo data // Writer for -XprintRounds and -XprintProcessorInfo data
...@@ -1218,7 +1220,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ...@@ -1218,7 +1220,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
return false; return false;
} }
private class AnnotationCollector extends TreeScanner { private static class AnnotationCollector extends TreeScanner {
List<JCTree> path = List.nil(); List<JCTree> path = List.nil();
static final boolean verbose = false; static final boolean verbose = false;
List<JCAnnotation> annotations = List.nil(); List<JCAnnotation> annotations = List.nil();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册