Aladdin - Scala Bugtracking
[#685] project: compiler priority: medium category: feature
submitter assigned to status date submitted
Burak _ _ 2006-08-01 19:03:33.0
subject support for java1.5
code
package evx;

// this is java1.5 code ... 

public enum Event {
    StartElem,
    EndElem,
    Literal
}

// and here's Scala code that uses it
parser.nextEvent() match {
   case Event.StartElem =>
   case Event.Literal =>
   case Event.EndElem =>
}
what happened
It seems like we support Java1.5 enums out of the box! Here's what javac 1.5 generates (the values are static me\
mbers of the Event class) :
[emir@lamppc31 xmlLibraryPush]$ javap -c -classpath classes evx.Event
Compiled from "Event.java"
public final class evx.Event extends java.lang.Enum{
public static final evx.Event StartElem;

public static final evx.Event EndElem;

public static final evx.Event Literal;

public static final evx.Event[] values();
  Code:
   0:   getstatic       #1; //Field $VALUES:[Levx/Event;
   3:   invokevirtual   #2; //Method "[Levx/Event;".clone:()Ljava/lang/Object;
   6:   checkcast       #3; //class "[Levx/Event;"
   9:   areturn

public static evx.Event valueOf(java.lang.String);
  Code:
   0:   ldc_w   #4; //class evx/Event
   3:   aload_0
   4:   invokestatic    #5; //Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum\
;
   7:   checkcast       #4; //class evx/Event
   10:  areturn

static {};
  Code:
   0:   new     #4; //class evx/Event
   3:   dup
   4:   ldc     #7; //String StartElem
   6:   iconst_0
   7:   invokespecial   #8; //Method "":(Ljava/lang/String;I)V
   10:  putstatic       #9; //Field StartElem:Levx/Event;
   13:  new     #4; //class evx/Event
   16:  dup
   17:  ldc     #10; //String EndElem
   19:  iconst_1
   20:  invokespecial   #8; //Method "":(Ljava/lang/String;I)V
   23:  putstatic       #11; //Field EndElem:Levx/Event;
   26:  new     #4; //class evx/Event
   29:  dup
   30:  ldc     #12; //String Literal
   32:  iconst_2
   33:  invokespecial   #8; //Method "":(Ljava/lang/String;I)V
   36:  putstatic       #13; //Field Literal:Levx/Event;
   39:  iconst_3
   40:  anewarray       #4; //class evx/Event
   43:  dup
   44:  iconst_0
   45:  getstatic       #9; //Field StartElem:Levx/Event;
   48:  aastore
   49:  dup
   50:  iconst_1
   51:  getstatic       #11; //Field EndElem:Levx/Event;
   54:  aastore
   55:  dup
   56:  iconst_2
   57:  getstatic       #13; //Field Literal:Levx/Event;
   60:  aastore
   61:  putstatic       #1; //Field $VALUES:[Levx/Event;
   64:  return

}
what expected People might ask for some more features related to Java1.5 enums.
[back to overview]
Changes of this bug report