Created
April 8, 2012 12:28
-
-
Save talya/d5dbe5e046a32e66b45d to your computer and use it in GitHub Desktop.
private member access via reflection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SomeClass objectWithPrivateMember = new SomeClass(); | |
Field privateMessageField = SomeClass.class.getDeclaredField("privateMessage"); | |
privateMessageField.setAccessible(true); | |
String privateMessage = (String)privateMessageField.get(objectWithPrivateMember); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment