获取指定类里所有的方法 返回类的方法数量
(Class klass,ClassInfo classInfo)
| 143 | * 返回类的方法数量 |
| 144 | */ |
| 145 | public static int loadAllMethodsWithClass(Class klass,ClassInfo classInfo) |
| 146 | { |
| 147 | //Log.i("AUPK", "ActivityThread:loadAllMethods from class:" + className); |
| 148 | int count=0; |
| 149 | try |
| 150 | { |
| 151 | if (klass == null) |
| 152 | { |
| 153 | return 0; |
| 154 | } |
| 155 | |
| 156 | // 获取目标类的所有构造函数 |
| 157 | Constructor constructors[] = klass.getDeclaredConstructors(); |
| 158 | for (Object constructor : constructors) |
| 159 | { |
| 160 | |
| 161 | String methodName=klass.getName()+constructor.toString(); |
| 162 | classInfo.methodMap.put(methodName,constructor); |
| 163 | count++; |
| 164 | } |
| 165 | |
| 166 | // 获取目标类的所有成员函数 |
| 167 | Method[] methods = klass.getDeclaredMethods(); |
| 168 | for (Method method : methods) |
| 169 | { |
| 170 | String methodName=klass.getName()+method.toString(); |
| 171 | classInfo.methodMap.put(methodName,method); |
| 172 | count++; |
| 173 | } |
| 174 | } |
| 175 | catch (Error | Exception e) |
| 176 | { |
| 177 | e.printStackTrace(); |
| 178 | } |
| 179 | return count; |
| 180 | } |
| 181 | |
| 182 | |
| 183 |
no test coverage detected