Why should compiler optimize obviously dumb code? If developer wants to create billions of heap objects, compiler should respect him. Optimizing dumb code is what made C++ unbearable. When you write one code and compilers generates completely different code.
The problem is rather that Java doesn't have generics and structs, so you're kind of forced to box things or can't use collections.