1.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Apr 12 12:05:04 2013 +0200 1.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Sat Apr 13 12:25:44 2013 +0100 1.3 @@ -25,6 +25,7 @@ 1.4 1.5 package com.sun.tools.javac.main; 1.6 1.7 +import com.sun.tools.javac.comp.CompileStates; 1.8 import java.io.*; 1.9 import java.util.HashMap; 1.10 import java.util.HashSet; 1.11 @@ -61,6 +62,7 @@ 1.12 import com.sun.tools.javac.tree.*; 1.13 import com.sun.tools.javac.tree.JCTree.*; 1.14 import com.sun.tools.javac.util.*; 1.15 +import com.sun.tools.javac.comp.CompileStates.CompileState; 1.16 import com.sun.tools.javac.util.Log.WriterKind; 1.17 1.18 import static com.sun.tools.javac.code.TypeTag.CLASS; 1.19 @@ -326,6 +328,8 @@ 1.20 **/ 1.21 protected boolean implicitSourceFilesRead; 1.22 1.23 + protected CompileStates compileStates; 1.24 + 1.25 /** Construct a new compiler using a shared context. 1.26 */ 1.27 public JavaCompiler(Context context) { 1.28 @@ -348,6 +352,7 @@ 1.29 1.30 fileManager = context.get(JavaFileManager.class); 1.31 parserFactory = ParserFactory.instance(context); 1.32 + compileStates = CompileStates.instance(context); 1.33 1.34 try { 1.35 // catch completion problems with predefineds 1.36 @@ -521,42 +526,6 @@ 1.37 */ 1.38 public List<Closeable> closeables = List.nil(); 1.39 1.40 - /** Ordered list of compiler phases for each compilation unit. */ 1.41 - public enum CompileState { 1.42 - INIT(0), 1.43 - PARSE(1), 1.44 - ENTER(2), 1.45 - PROCESS(3), 1.46 - ATTR(4), 1.47 - FLOW(5), 1.48 - TRANSTYPES(6), 1.49 - UNLAMBDA(7), 1.50 - LOWER(8), 1.51 - GENERATE(9); 1.52 - 1.53 - CompileState(int value) { 1.54 - this.value = value; 1.55 - } 1.56 - boolean isAfter(CompileState other) { 1.57 - return value > other.value; 1.58 - } 1.59 - public static CompileState max(CompileState a, CompileState b) { 1.60 - return a.value > b.value ? a : b; 1.61 - } 1.62 - private final int value; 1.63 - }; 1.64 - /** Partial map to record which compiler phases have been executed 1.65 - * for each compilation unit. Used for ATTR and FLOW phases. 1.66 - */ 1.67 - protected class CompileStates extends HashMap<Env<AttrContext>,CompileState> { 1.68 - private static final long serialVersionUID = 1812267524140424433L; 1.69 - boolean isDone(Env<AttrContext> env, CompileState cs) { 1.70 - CompileState ecs = get(env); 1.71 - return (ecs != null) && !cs.isAfter(ecs); 1.72 - } 1.73 - } 1.74 - private CompileStates compileStates = new CompileStates(); 1.75 - 1.76 /** The set of currently compiled inputfiles, needed to ensure 1.77 * we don't accidentally overwrite an input file when -s is set. 1.78 * initialized by `compile'. 1.79 @@ -1395,13 +1364,17 @@ 1.80 @Override 1.81 public void visitClassDef(JCClassDecl node) { 1.82 Type st = types.supertype(node.sym.type); 1.83 - if (st.hasTag(CLASS)) { 1.84 + boolean envForSuperTypeFound = false; 1.85 + while (!envForSuperTypeFound && st.hasTag(CLASS)) { 1.86 ClassSymbol c = st.tsym.outermostClass(); 1.87 Env<AttrContext> stEnv = enter.getEnv(c); 1.88 if (stEnv != null && env != stEnv) { 1.89 - if (dependencies.add(stEnv)) 1.90 + if (dependencies.add(stEnv)) { 1.91 scan(stEnv.tree); 1.92 + } 1.93 + envForSuperTypeFound = true; 1.94 } 1.95 + st = types.supertype(st); 1.96 } 1.97 super.visitClassDef(node); 1.98 }