java.util.PriorityQueue
在学CB链之前我们需要回忆一下java.util.PriorityQueue,这个类是我们CC2的入口点。我们回忆一下CC2的链子
1
| java.util.PriorityQueue#readObject->heapify->siftDown->siftDownUsingComparator->TransformingComparator#compare->xxx#transform
|
在CC2中我们就已经知道了PriorityQueue可以调用到xxx.compare而在CB1中也是利用了这个来寻找compare类
commons.beanutils
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| package CB; import org.apache.commons.beanutils.*;
import java.lang.reflect.InvocationTargetException; import java.util.HashMap;
public class test { public static void main(String[] args) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { testBean bean = new testBean(); String Name = (String) PropertyUtils.getProperty(bean, "name"); PropertyUtils.setProperty(bean, "name", "Bob"); System.out.println(bean.getname());
HashMap map = new HashMap(); map.put("name", "xiaoming");
BeanUtils.populate(bean, map); BeanUtils.setProperty(bean, "age", "23"); System.out.println(bean.getname()); System.out.println(bean.getage());
} }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| package CB;
public class testBean { public String name="xiaoli"; public Integer age;
public Integer getage(){ return age; }
public void setage(Integer age){ this.age=age; }
public String getname(){ return name; } public void setname(String name){ this.name = name; }
}
|