| 13 | import java.util.ArrayList; |
| 14 | |
| 15 | public class Test { |
| 16 | public static String getData(String fileName) { |
| 17 | String Path="src\\test\\java\\com\\" + fileName + ".json"; |
| 18 | BufferedReader reader = null; |
| 19 | StringBuilder laststr = new StringBuilder(); |
| 20 | try { |
| 21 | FileInputStream fileInputStream = new FileInputStream(Path); |
| 22 | InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8); |
| 23 | reader = new BufferedReader(inputStreamReader); |
| 24 | String tempString; |
| 25 | while ((tempString = reader.readLine()) != null) { |
| 26 | laststr.append(tempString); |
| 27 | } |
| 28 | reader.close(); |
| 29 | } catch (IOException e) { |
| 30 | e.printStackTrace(); |
| 31 | } finally { |
| 32 | if (reader != null) { |
| 33 | try { |
| 34 | reader.close(); |
| 35 | } catch (IOException e) { |
| 36 | e.printStackTrace(); |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | return laststr.toString(); |
| 41 | } |
| 42 | public static String get_ClassName(JsonNode results, int chain_id, int node_id) { |
| 43 | JsonNode ClassName = results.get(chain_id).get("ClassName"); |
| 44 | String classname = null; |
| 45 | for (int i=0; i<ClassName.size(); i++) { |
| 46 | if (ClassName.get(i).get("id").intValue() == node_id) { |
| 47 | classname = ClassName.get(i).get("value").textValue(); |
| 48 | break; |
| 49 | } |
| 50 | } |
| 51 | return classname; |
| 52 | } |
| 53 | |
| 54 | public static String get_MethodName(JsonNode results, int chain_id, int node_id) { |
| 55 | JsonNode MethodName = results.get(chain_id).get("MethodName"); |
| 56 | String methodname = null; |
| 57 | for (int i=0; i<MethodName.size(); i++) { |
| 58 | if (MethodName.get(i).get("id").intValue() == node_id) { |
| 59 | methodname = MethodName.get(i).get("value").textValue(); |
| 60 | break; |
| 61 | } |
| 62 | } |
| 63 | return methodname; |
| 64 | } |
| 65 | |
| 66 | public static <classname> Object object_init(String classname) throws Exception { |
| 67 | |
| 68 | Class<?> target_classname = Class.forName(classname); //返回传入类对应的实例对象 |
| 69 | Field f = Unsafe.class.getDeclaredField("theUnsafe"); |
| 70 | f.setAccessible(true); |
| 71 | Unsafe unsafe = (Unsafe) f.get(null); |
| 72 |
nothing calls this directly
no outgoing calls
no test coverage detected