80,351
社区成员
发帖
与我相关
我的任务
分享
@SuppressWarnings("unchecked")
public static <T> T getProxy(Class<T> c) {
return (T) Proxy.newProxyInstance(HttpProxy.class.getClassLoader(),
new Class<?>[] { c }, handler);
}
static class HttpInvocationHandler implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
if (args != null && args.length > 1) {
// 协议只支持一个参数
throw new IllegalArgumentException("Arg's count must be 1");
}
// 协议中URL的格式为 前缀 +类名 +方法名。
String url = "url";
Object obj = null;
try {
//这里抛出了一个自定义异常
obj = sendAndReceive(url,
args == null || args.length < 1 ? null : args[0],
method.getReturnType(), method.getName());
//自定义异常
}catch (CustomeException e) {
//这里也抛出了
throw e;
}
return obj;
}
}
try {
Res resp = HttpProxy.getProxy(IMODEL.class).login();
if (res != null){
return ok;
}
LogUtil.i(TAG, " 通知知识点主界面 以及 知识点");
} catch (CustomeException e) {
//混淆前代码走这里,混淆后代码没走这里
LogUtil.e(TAG, Log.getStackTraceString(e));
} catch(Exception e){
//混淆后走了这里
}