News for hackers. Stuff that matters.
Re:Java is very fast, if you don’t create many objects by kjeetgill on Monday September 12, 2022 @09:34AM (#32809974)
Hmmm. As much as I hate having to fix boxing problems, I usually find it pretty obvious when boxing can occur. Pretty much any time a variable/parameter type or a function return type uses capitalized Integer, Long, Boolean, etc. instead of lowercase int, long, boolean, etc. boxing is probably occurring. Those ... and assigning those to Object or Number.

I think that's exhaustive. You can pretty much grep through and remove them from 90 % of coffee with a little refactoring and replacing HashMaps with specialized ones. Only if there's null returns or ConcurrentHashMaps involved does it get tricky.

An array of primitives like byte[] or long[] isn't Byte[] or Long[]. The former don't cause boxing. Maybe you're thinking of ArrayList<Byte>?

Re:Java is very fast, if you don’t create many objects by WastingMyTime89 on Monday September 12, 2022 @10:06AM (#32810471)
> Pretty much any time a variable/parameter type or a function return type uses capitalized Integer, Long, Boolean, etc. instead of lowercase int, long, boolean, etc. boxing is probably occurring.

That probably occurring hides a lot of complexity. That’s my original point. Optimisations are happening especially when Integer and Long are involved. There are sometimes actually less boxing than you would expect reading the code.

Re:Java is very fast, if you don’t create many objects by kjeetgill on Monday September 12, 2022 @11:08AM (#32811493)
True, but I'd argue you should treat those probable boxing situations and definitely boxing and remove them.