Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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

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



Such hacks will slowly stop working (without explicitly allowing it from the command line.)

In this example, it would throw an IllegalAccessException, because java.base doesn't open java.lang.


Doesn’t field.setAccessible(true) already throw on a modern version?


Exactly.

You can make it not throw by adding `--add-opens java.base/java.lang=ALL-UNNAMED` or similar to the command line, but breaking things like this is becoming harder.


In Python 2 you could literally do

    True = False
and of course in JavaScript

    undefined = "a string"


The terrifying part of this in Java, is that it applies program-wide, including to constants set before you changed the value




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: