Home » openjdk-7 » com.sun.tools » javac » comp » [javadoc | source]
com.sun.tools.javac.comp
class: Lower.EnumMapping [javadoc | source]
java.lang.Object
   com.sun.tools.javac.comp.Lower$EnumMapping
This map gives a translation table to be used for enum switches.

For each enum that appears as the type of a switch expression, we maintain an EnumMapping to assist in the translation, as exemplified by the following example:

we translate

         switch(colorExpression) {
         case red: stmt1;
         case green: stmt2;
         }
 
into
         switch(Outer$0.$EnumMap$Color[colorExpression.ordinal()]) {
         case 1: stmt1;
         case 2: stmt2
         }
 
with the auxiliary table initialized as follows:
         class Outer$0 {
             synthetic final int[] $EnumMap$Color = new int[Color.values().length];
             static {
                 try { $EnumMap$Color[red.ordinal()] = 1; } catch (NoSuchFieldError ex) {}
                 try { $EnumMap$Color[green.ordinal()] = 2; } catch (NoSuchFieldError ex) {}
             }
         }
 
class EnumMapping provides mapping data and support methods for this translation.
Field Summary
 DiagnosticPosition pos     
 int next     
final  TypeSymbol forEnum     
final  VarSymbol mapVar     
final  Map<VarSymbol, Integer> values     
Constructor:
 EnumMapping(DiagnosticPosition pos,
    TypeSymbol forEnum) 
Method from com.sun.tools.javac.comp.Lower$EnumMapping Summary:
forConstant,   translate
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.tools.javac.comp.Lower$EnumMapping Detail:
 JCLiteral forConstant(VarSymbol v) 
  void translate()