| Java - Read a private member variable through reflection |
|
|
|
| Written by Steve Leonard |
| Thursday, 05 March 2009 11:09 |
|
Sometimes you are writing a test class and want to check that the class you are testing is being changed the way you expect. When a class has private menbers that you don't want to open up to anyone, you can use reflection to see them. This is a simple example. import java.lang.reflect.Field; class ExampleClass {
// set accessible true
|
| Last Updated on Thursday, 05 March 2009 11:12 |