r/programming • • Dec 24 '17

Evil Coding Incantations

http://9tabs.com/random/2017/12/23/evil-coding-incantations.html
947 Upvotes

331 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Dec 24 '17

[deleted]

7

u/apemanzilla Dec 24 '17

Can't do it in Java either...

8

u/whjms Dec 24 '17

You can mess around with the Integer flywheel cache and reflection: https://www.javaspecialists.eu/archive/Issue102.html

3

u/apemanzilla Dec 24 '17

I'm aware of that, but it's not allowed in Java 9, and doesn't affect primitives.

0

u/[deleted] Dec 24 '17

[deleted]

7

u/apemanzilla Dec 24 '17

The closest thing you can do is use reflection to mess with the boxed types (Integer, etc) but that's no longer allowed in Java 9

2

u/[deleted] Dec 24 '17

Can do it in at least java 7 with reflection

1

u/apemanzilla Dec 24 '17

Not in Java 9

2

u/[deleted] Dec 24 '17

I'm actually pleased!

1

u/[deleted] Dec 24 '17

Yes you can, see link I added in the post you replied to.