Is it the compiler or the runtime do the auto-boxing/unboxing?
Consider the following example:
public Integer get() {
return 1; //(1)
}
At (1), the primitive integer value will be converted into something like new Integer(1)
, and returned. That's effectively some kind of implict consverion known as auto-boxing , but who will do that? The compiler, or the JVM?
I was just starting to learn the ASM, and such boxing issue really confuse me.
Integer b = Integer.valueOf(a);
. Simple. It doesn't need to know the value ofa
. See also the accepted answer to this question. – Applicable