3 ms·
In java private variables and functions are not accessible from outside the class. Not quite - using reflection you can dig into private fields and do your wor
by ewjordan 16y ago
In java private variables and functions are not accessible from outside the class.
Not quite - using reflection you can dig into private fields and do your worst to them, you just need to tag each private member's Field object with with field.setAccessible(true) before accessing it reflectively.
The only hitch is that you might get a SecurityException, but you can avoid that if you're running your code on your own JVM (by default, it should work just fine, it's if you're deploying applets or something like that where you might get the exception due to the different sandboxing rules).