How private are private fields after all?

Last week, I sent the following brain teaser: public class Foo { private int secret = 47; public Foo() { new Hacker().hack(this); } public String tellSecret() { return String.valueOf(secret); } public static void main(String[] args) { System.out.println(”How secret are private members? ..”); System.out.println(”Psst: ” + new Foo().tellSecret(); } } Can you write a void hack(Object […]