a Cross Development Platform for Java

User Tools

Site Tools



Enumerations are supported. In an enum class two synthetic methods are created in the Bystecode.

  • values(): returns an array with all values, uses System.arraycopy
  • valueOf(String name): returns the value with the name name. This method calls valueOf of the class Enum. Though with a slightly different signature than what is present in our runtime library. That's why this case must be specially handled by the class file reader. Further, in the SSA a reference to the field ENUM$VALUES (which is synthetic as well) must be loaded. Finally, during code generation the address of this field has to be loaded and the reference to it must be fetched.

If enum values are used in a switch statement, a special field $SWITCH_TABLE$CLASSNAME will be created in the class with the switch statement. Further, a method is generated with the signature static int[] $SWITCH_TABLE$CLASSNAME(). This method is called before the first use of the switch statement. It initializes an int-array with the ordinal numbers of the enum entries.
An excellent reference to the internals of enums can be found at

dev/rts/enums.txt · Last modified: 2016/02/25 13:33 by