logoalt Hacker News

swiftcodertoday at 7:29 AM2 repliesview on HN

Of particular note, all 1-byte Integers are interned, there is a pool of small Integers from -127 <-> 127 which are reused whenever possible.

I learned this the hard way, when a C++ JNI extension I was working on accidentally overwrote the pooled value for zero, and all hell broke loose...


Replies

agilobtoday at 8:17 AM

> Integers from -127 <-> 127

The cache can be extended on startup with env var `java.lang.Integer.IntegerCache.high `

https://github.com/openjdk/jdk/blob/cc278dbb8a1ca0754d584270...

show 1 reply
tpmtoday at 12:00 PM

Yeah - it's a bit non-intuitive you can change the value of a number.

https://thedailywtf.com/articles/Disgruntled-Bomb-Java-Editi...

show 1 reply