src/share/classes/com/sun/tools/javac/comp/TransTypes.java

changeset 1690
76537856a54e
parent 1521
71f35e4b93a5
child 1696
c2315af9cc28
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Fri Apr 12 12:05:04 2013 +0200
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Sat Apr 13 12:25:44 2013 +0100
     1.3 @@ -40,6 +40,7 @@
     1.4  import static com.sun.tools.javac.code.TypeTag.CLASS;
     1.5  import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
     1.6  import static com.sun.tools.javac.code.TypeTag.VOID;
     1.7 +import static com.sun.tools.javac.comp.CompileStates.CompileState;
     1.8  
     1.9  /** This pass translates Generic Java to conventional Java.
    1.10   *
    1.11 @@ -77,8 +78,11 @@
    1.12       */
    1.13      private final boolean addBridges;
    1.14  
    1.15 +    private final CompileStates compileStates;
    1.16 +
    1.17      protected TransTypes(Context context) {
    1.18          context.put(transTypesKey, this);
    1.19 +        compileStates = CompileStates.instance(context);
    1.20          names = Names.instance(context);
    1.21          log = Log.instance(context);
    1.22          syms = Symtab.instance(context);
    1.23 @@ -904,16 +908,40 @@
    1.24  
    1.25      private Env<AttrContext> env;
    1.26  
    1.27 +    private static final String statePreviousToFlowAssertMsg =
    1.28 +            "The current compile state [%s] of class %s is previous to FLOW";
    1.29 +
    1.30      void translateClass(ClassSymbol c) {
    1.31          Type st = types.supertype(c.type);
    1.32 -
    1.33          // process superclass before derived
    1.34 -        if (st.hasTag(CLASS))
    1.35 +        if (st.hasTag(CLASS)) {
    1.36              translateClass((ClassSymbol)st.tsym);
    1.37 +        }
    1.38  
    1.39          Env<AttrContext> myEnv = enter.typeEnvs.remove(c);
    1.40 -        if (myEnv == null)
    1.41 +        if (myEnv == null) {
    1.42              return;
    1.43 +        }
    1.44 +
    1.45 +        /*  The two assertions below are set for early detection of any attempt
    1.46 +         *  to translate a class that:
    1.47 +         *
    1.48 +         *  1) has no compile state being it the most outer class.
    1.49 +         *     We accept this condition for inner classes.
    1.50 +         *
    1.51 +         *  2) has a compile state which is previous to Flow state.
    1.52 +         */
    1.53 +        boolean envHasCompState = compileStates.get(myEnv) != null;
    1.54 +        if (!envHasCompState && c.outermostClass() == c) {
    1.55 +            Assert.error("No info for outermost class: " + myEnv.enclClass.sym);
    1.56 +        }
    1.57 +
    1.58 +        if (envHasCompState &&
    1.59 +                CompileState.FLOW.isAfter(compileStates.get(myEnv))) {
    1.60 +            Assert.error(String.format(statePreviousToFlowAssertMsg,
    1.61 +                    compileStates.get(myEnv), myEnv.enclClass.sym));
    1.62 +        }
    1.63 +
    1.64          Env<AttrContext> oldEnv = env;
    1.65          try {
    1.66              env = myEnv;

mercurial