A boxed value is unboxed and then immediately reboxed. This has likely occurred due to an unboxing operation by the programmer, which the java compiler has undone.
public void acceptsInteger(Integer x) { ... }
Integer a = 0;
Float b = 1f;
// Same type, unboxed.
acceptsInteger(a.intValue());
// Different type, unboxed.
acceptsInteger(b.intValue());
The bytecode for the first call would look something like:
aload_1 // Load `a` into memory.
invokevirtual #13 // Call instance method `Integer.intValue()` on `a`
invokestatic #7 // Call static method `Integer.valueOf()` with the result of `intValue()`
invokestatic #23 // Call instance method `acceptsInteger()`
Note two contradicting method calls: this code calls Integer.intValue()
immediately followed by Integer.valueOf()
.
If a method expects a boxed type, it is better to provide it a value that is of the same type than to give it one of a different one.
acceptsInteger(a);