Anonymous user
Break OO privacy: Difference between revisions
→{{header|Java}}
(SmileBASIC not OO enough :{) |
|||
Line 648:
</pre>
All classes are vulnerable to this, including <code>String</code> (and therefore, string literals). How long is the word "cat"?
(Note: somewhere between Java 8 and Java 11 this stopped working because the <code>value</code> field of <code>String</code> is <code>final</code>. The reflective access is still possible, but changing a final field isn't.)
<lang Java>import java.lang.reflect.*;
public class BreakString{
|