In general, I agree with @Christian, but I have two more notes:
1 JVM main() . main(). , . , main() , , AFAIC. main() .
2 , Core Reflection API . :
import java.lang.reflect.Field;
class SimpleKeyPair {
private String privateKey = "Cafe Babe";
}
public class PrivateMemberAccessTest {
public static void main(String[] args) throws Exception {
SimpleKeyPair keyPair = new SimpleKeyPair();
Class c = keyPair.getClass();
Field field = c.getDeclaredField("privateKey");
field.setAccessible(true);
System.out.println("Value of privateKey: " + field.get(keyPair));
field.set(keyPair, "Java Duke");
System.out.println("Value of privateKey: " + field.get(keyPair));
}
}
http://www.jguru.com/faq/view.jsp?EID=321191
. fooobar.com/questions/18746/...