
JVM Code Generation 191
Casting an int to an Integer is called boxing and requires an invocation of the Integer
.valueOf() method:
invoke s t atic java / lang / I n t e g e r . valueOf :(I ) Ljava / lang / Integer ;
Casting an Integer to an int is called unboxing and requires an invocation of the
Integer.intValue() method:
invok e v irtua l java / lang / Integer . intValue :() I
Certain casts, from one primitive type to another, require that a special instruction be
executed. For example, the i2c instruction converts an int to a char. There is a Converter
defined for each valid conversion in j--.
5.8 Further Readings
[Lindholm and Yellin, 1999] is the