6930032: fix findbugs errors in com.sun.tools.javac.comp

Reviewed-by: darcy
This commit is contained in:
Jonathan Gibbons 2010-02-26 15:30:35 -08:00
parent 9ce36383eb
commit a5c51fcd1d
2 changed files with 17 additions and 13 deletions

View File

@ -270,6 +270,7 @@ public class Enter extends JCTree.Visitor {
return ts.toList(); return ts.toList();
} }
@Override
public void visitTopLevel(JCCompilationUnit tree) { public void visitTopLevel(JCCompilationUnit tree) {
JavaFileObject prev = log.useSource(tree.sourcefile); JavaFileObject prev = log.useSource(tree.sourcefile);
boolean addEnv = false; boolean addEnv = false;
@ -289,13 +290,13 @@ public class Enter extends JCTree.Visitor {
tree.packge = syms.unnamedPackage; tree.packge = syms.unnamedPackage;
} }
tree.packge.complete(); // Find all classes in package. tree.packge.complete(); // Find all classes in package.
Env<AttrContext> env = topLevelEnv(tree); Env<AttrContext> topEnv = topLevelEnv(tree);
// Save environment of package-info.java file. // Save environment of package-info.java file.
if (isPkgInfo) { if (isPkgInfo) {
Env<AttrContext> env0 = typeEnvs.get(tree.packge); Env<AttrContext> env0 = typeEnvs.get(tree.packge);
if (env0 == null) { if (env0 == null) {
typeEnvs.put(tree.packge, env); typeEnvs.put(tree.packge, topEnv);
} else { } else {
JCCompilationUnit tree0 = env0.toplevel; JCCompilationUnit tree0 = env0.toplevel;
if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) { if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) {
@ -306,7 +307,7 @@ public class Enter extends JCTree.Visitor {
if (addEnv || (tree0.packageAnnotations.isEmpty() && if (addEnv || (tree0.packageAnnotations.isEmpty() &&
tree.docComments != null && tree.docComments != null &&
tree.docComments.get(tree) != null)) { tree.docComments.get(tree) != null)) {
typeEnvs.put(tree.packge, env); typeEnvs.put(tree.packge, topEnv);
} }
} }
} }
@ -322,14 +323,15 @@ public class Enter extends JCTree.Visitor {
c.members_field = new Scope(c); c.members_field = new Scope(c);
tree.packge.package_info = c; tree.packge.package_info = c;
} }
classEnter(tree.defs, env); classEnter(tree.defs, topEnv);
if (addEnv) { if (addEnv) {
todo.append(env); todo.append(topEnv);
} }
log.useSource(prev); log.useSource(prev);
result = null; result = null;
} }
@Override
public void visitClassDef(JCClassDecl tree) { public void visitClassDef(JCClassDecl tree) {
Symbol owner = env.info.scope.owner; Symbol owner = env.info.scope.owner;
Scope enclScope = enterScope(env); Scope enclScope = enterScope(env);
@ -435,6 +437,7 @@ public class Enter extends JCTree.Visitor {
* Enter a symbol for type parameter in local scope, after checking that it * Enter a symbol for type parameter in local scope, after checking that it
* is unique. * is unique.
*/ */
@Override
public void visitTypeParameter(JCTypeParameter tree) { public void visitTypeParameter(JCTypeParameter tree) {
TypeVar a = (tree.type != null) TypeVar a = (tree.type != null)
? (TypeVar)tree.type ? (TypeVar)tree.type
@ -448,6 +451,7 @@ public class Enter extends JCTree.Visitor {
/** Default class enter visitor method: do nothing. /** Default class enter visitor method: do nothing.
*/ */
@Override
public void visitTree(JCTree tree) { public void visitTree(JCTree tree) {
result = null; result = null;
} }
@ -489,10 +493,8 @@ public class Enter extends JCTree.Visitor {
for (JCCompilationUnit tree : trees) { for (JCCompilationUnit tree : trees) {
if (tree.starImportScope.elems == null) { if (tree.starImportScope.elems == null) {
JavaFileObject prev = log.useSource(tree.sourcefile); JavaFileObject prev = log.useSource(tree.sourcefile);
Env<AttrContext> env = typeEnvs.get(tree); Env<AttrContext> topEnv = topLevelEnv(tree);
if (env == null) memberEnter.memberEnter(tree, topEnv);
env = topLevelEnv(tree);
memberEnter.memberEnter(tree, env);
log.useSource(prev); log.useSource(prev);
} }
} }

View File

@ -607,10 +607,12 @@ public class TransTypes extends TreeTranslator {
public void visitNewArray(JCNewArray tree) { public void visitNewArray(JCNewArray tree) {
tree.elemtype = translate(tree.elemtype, null); tree.elemtype = translate(tree.elemtype, null);
translate(tree.dims, syms.intType); translate(tree.dims, syms.intType);
tree.elems = translate(tree.elems, if (tree.type != null) {
(tree.type == null) ? null tree.elems = translate(tree.elems, erasure(types.elemtype(tree.type)));
: erasure(types.elemtype(tree.type))); tree.type = erasure(tree.type);
tree.type = erasure(tree.type); } else {
tree.elems = translate(tree.elems, null);
}
result = tree; result = tree;
} }