Can anoyne recommend a good library that will let me easily read/write private member fields of a class? I was looking through apache commons, but couldnt see it. I must be getting blind ?
Edit: Asking questions on the border of legalities always give these questions of ‘why’? I am writing several javarebel plugins for hotswapping classes. Accessing private variables is only step 1, I might even have to replace implementations of some methods.
In most of the cases java reflection solves the problem:
Example:
Now the Reflection Code:
UPDATE:
It’s worth mentioning that this approach can be thwarted by a SecurityManager. – Dan Dyer