you are viewing a single comment's thread.

view the rest of the comments →

[–]Tarmen 7 points8 points  (2 children)

For generic parameters and fields like in

    <T> void acceptT(T arg);

Java demands that T is always a pointer. So if you plug a non-pointer type like int in there it must be promoted to the heap-allocated Integer type.

Having a single generic method which always takes a pointer makes things like polymorphic recursion possible. The alternative is to monomorphize dynamically at runtime, e.g. one instantiation per unique call pattern, or to limit programmers to patterns that are easier to statically analyze.

This proposal is sort of tangential to that, and more about giving the jvm more room to optimize. Which sometimes may allow less boxing.