// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class Hack {
    private static sun.misc.Unsafe unsafe;
    static {
        try {
            java.lang.reflect.Field f = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
            f.setAccessible(true);
            unsafe = (sun.misc.Unsafe)f.get(null);
        } catch(Exception ex) {
            ex.printStackTrace();
        }
    }
    public static class Demo {
        private int v;
        public Demo() {
            init();
        }
        public void init() {
            v = 123;
        }
        @Override
        public String toString() {
            return String.format("[v=%d]", v);
        }
    }
    public static void main(String[] args) throws InstantiationException {
        Demo o1 = new Demo();
        System.out.println(o1);
        Demo o2 = (Demo)unsafe.allocateInstance(Demo.class);
        System.out.println(o2);
        o2.init();
        System.out.println(o2);
    }
}
