MCPcopy Create free account
hub / github.com/GCMiner/GCMiner / generate

Method generate

src/main/java/com/ExploitGenerator.java:73–178  ·  view source on GitHub ↗
(SourceOfRandomness random, GenerationStatus status)

Source from the content-addressed store, hash-verified

71
72
73 @Override
74 public Object generate(SourceOfRandomness random, GenerationStatus status) {
75 HashMap hashMap = new HashMap<>();
76 hashMap.put("key", "value");
77
78 for (int idx = 0; idx < dictionary.size() - 1; idx++) {
79 if (!HashMap.class.isAssignableFrom(dictionary.get(idx).getClass())
80 && Map.class.isAssignableFrom(dictionary.get(idx).getClass())) {
81 Field mapField = null;
82 try {
83 mapField = dictionary.get(idx).getClass().getSuperclass().getDeclaredField("map");
84 } catch (NoSuchFieldException e) {
85 //e.printStackTrace();
86 }
87 mapField.setAccessible(true);
88 try {
89 mapField.set(dictionary.get(idx), hashMap);
90 } catch (IllegalAccessException e) {
91 //e.printStackTrace();
92 }
93 }
94
95 //Field[] target_field = dictionary.get(idx).getClass().getDeclaredFields();//获取所有属性
96 Field[] target_field = FieldUtils.getAllFields(dictionary.get(idx).getClass());
97 for (Field field : target_field) {
98 field.setAccessible(true);
99 if (!Modifier.isStatic(field.getModifiers())) {
100 if (field.getType().isAssignableFrom(dictionary.get(idx + 1).getClass())) {
101 try {
102 field.set(dictionary.get(idx), dictionary.get(idx + 1));
103 } catch (IllegalAccessException e) {
104 //e.printStackTrace();
105 }
106 continue;
107 }
108 if (field.getType() == int.class) {
109 try {
110 field.set(dictionary.get(idx), random.nextInt(0, 5));
111 } catch (IllegalAccessException e) {
112 //e.printStackTrace();
113 }
114 }
115 if (Map.class.isAssignableFrom(field.getType())) {
116 try {
117 field.set(dictionary.get(idx), hashMap);
118 } catch (IllegalAccessException e) {
119 //e.printStackTrace();
120 }
121 }
122 if (field.getType() == Object.class) {
123 try {
124 field.set(dictionary.get(idx), random.choose(memberDictionary));
125 } catch (IllegalAccessException e) {
126 //e.printStackTrace();
127 }
128 }
129 if (field.getType().isArray()) {
130 int depth = geom.sampleWithMean(MEAN_ARRAY_DEPTH, random);

Callers

nothing calls this directly

Calls 1

getClassMethod · 0.80

Tested by

no test coverage detected