- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Java autoboxing exists since Java 1.5 so in the early 2000's it was not yet possible.
Apart from that, atrocious
Admin
I can imagine a lonely person boxing gifts for themselves, leaving them on the porch, then unboxing them the next day. A very lonely person, bordering on mental issues.
Admin
No, the person boxes the gifts for others they have never met, leave the gifts on the porch, and when the Amazon Delivery Thief takes it and unboxes it the next day, the thief is in for a surprise! How much damage can a booby-trap do before it is considered a criminal act?
Admin
While definitely a sarin-leveI code smell, I don't think this would be a performance issue with modern Java - looks easy enough to optimize away. Back then - I'm not so sure...
Admin
This makes me want to box someone's ears.
Admin
Was expecting the story to lead to much worse code. This isn't that bad, it doesn't crash or do something completely wrong.
Admin
Invented on boxing day?
Admin
Hmm ... wonder if that's the company I worked at in the 2010's ...
Admin
"How much damage can a booby-trap do before it is considered a criminal act?" Two words: Glitter bomb.
Admin
But why would you add a compiler optimization for something as inane as this? What legit scenario would something similar appear in, barring brain death?
Admin
Hire people you don't know to build something you know nothing about who themselves probably know nothing about it and you expect to get... something? Sadly I experienced the aftermath of exactly this scenario and basically rewrote it all.
Admin
Been there, done that, got the neurosis.
Admin
I think fireworks should be legal everywhere and if opening a box by a thief ACCIDENTALLY sets of a ginormous explosion, it would be perfectly reasonable - committing crimes is hazardous, you know.
Admin
It's not optimized away, partially for the reasons you gave and partially because the JLS makes certain guarantees when you call
new
. It was never a good idea to rely on them for boxed types (Integer
and so on), but enough projects do that changing them was considered a non-starter. The boxed types' constructors have recently been marked as deprecated for removal to change that state of affairs.There's also work being done to further address the weirdness of boxed types (among other things).
Admin
As an aside, don't do this. You'd be on the hook for at least reckless endangerment.
(Well, okay, if you ordered fireworks somewhere where that's legal and the thief actually managed to set them off by accident, that's a different matter. If you arrange for them to """accidentally""" set them off, well...)
Admin
"Come on, guys! This company's paying us millions of bucks. Let's not simply pass a 0 as an argument - spice it up a little!"
Admin
It just betrays a complete lack of understanding of such esoterica as checks notes primitives... and objects.
Admin
What's in the box?
Pain.
Admin
It's fair to say that they got something. Something bad (or maybe worse than that), but definitely something.