MCPcopy Create free account
hub / github.com/BeichenDream/InjectJDBC / getMethodSignature

Method getMethodSignature

src/com/abc/Main.java:67–122  ·  view source on GitHub ↗
(Method method)

Source from the content-addressed store, hash-verified

65 return new File(fileString).toString();
66 }
67 public static String getMethodSignature(Method method) {
68 StringBuilder s = new StringBuilder();
69 Class[] types = new Class[method.getParameterTypes().length + 1];
70 String[] typeStrArr = new String[types.length];
71 System.arraycopy(method.getParameterTypes(),0,types,0,types.length-1);
72 types[types.length-1] = method.getReturnType();
73
74
75
76 for (int i = 0; i < types.length; i++) {
77 Class type = types[i];
78 boolean isArray = type.isArray();
79 if (isArray) {
80 type = type.getComponentType();
81 }
82
83 if (int.class.equals(type)) {
84 typeStrArr[i] = "I";
85 }else if (void.class.equals(type)) {
86 typeStrArr[i] = "V";
87 }else if (boolean.class.equals(type)) {
88 typeStrArr[i] = "Z";
89 }else if (char.class.equals(type)) {
90 typeStrArr[i] = "C";
91 }else if (byte.class.equals(type)) {
92 typeStrArr[i] = "B";
93 }else if (short.class.equals(type)) {
94 typeStrArr[i] = "S";
95 }else if (float.class.equals(type)) {
96 typeStrArr[i] = "F";
97 }else if (long.class.equals(type)) {
98 typeStrArr[i] = "J";
99 }else if (double.class.equals(type)) {
100 typeStrArr[i] = "D";
101 }else {
102 typeStrArr[i] ="L" + type.getName().replace(".","/")+";";
103 }
104
105 if (isArray){
106 typeStrArr[i] = "[" + typeStrArr[i];
107 }
108
109 }
110
111 s.append("(");
112
113 for (int i = 0; (i < typeStrArr.length-1); i++) {
114 s.append(typeStrArr[i]);
115 }
116
117 s.append(")");
118
119 s.append(typeStrArr[typeStrArr.length -1]);
120
121 return s.toString();
122 }
123
124 public static void agentmain(String agentArg, Instrumentation inst){

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected