// AspectJ allows privileged aspects, but you can also use aspectJ to stop a // regular java program from accessing private elements using reflection... import java.lang.reflect.AccessibleObject; aspect privateguard { before(Object a): call(public void AccessibleObject+.setAccessible(..)) && target(a) { throw new Error("Motherhacker is trying to use reflection to access "+a); } } // Compile with any java source: ajc -8 blah.java privateguard.java. // Generated .class file will always deny setAccessible. -8 sets jdk1.8 // compatibility for ajc