removed 1st edition code

This commit is contained in:
Luciano Ramalho
2020-03-11 18:03:55 -03:00
parent 1be97eea3e
commit 506d343843
460 changed files with 0 additions and 108428 deletions

View File

@@ -1,25 +0,0 @@
import java.lang.reflect.Field;
public class Expose {
public static void main(String[] args) {
Confidential message = new Confidential("top secret text");
Field secretField = null;
try {
secretField = Confidential.class.getDeclaredField("secret");
}
catch (NoSuchFieldException e) {
System.err.println(e);
System.exit(1);
}
secretField.setAccessible(true); // break the lock!
try {
String wasHidden = (String) secretField.get(message);
System.out.println("message.secret = " + wasHidden);
}
catch (IllegalAccessException e) {
// this will not happen after setAcessible(true)
System.err.println(e);
}
}
}