You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to Scala version 2.9.1.final (JavaHotSpot(TM) 64-BitServerVM, Java1.7.0).
Type in expressions to have them evaluated.
Type:help for more information.
scala>objectStateextendsEnumeration {
|valIDLE, STARTED=Value|varx=IDLE| }
defined module State
scala>State.x
res0:State.Value=IDLE
scala>State.IDLE
res1:State.Value=IDLE
On OpenJDK, it prints "x" instead of "IDLE" because the name of the var is accidentally picked up instead of the intended field name. This is implementation-dependent: "The elements in the array returned are not sorted and are not in any particular order" ([http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html#getMethods()]).
There's probably not much we can do about this unless we can use Scala reflection instead of Java reflection to get the fields in the correct order.