Android Cannot Catch Custom Exception Invoked By Invoke

public class HttpProxy{
   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 {


    Object obj = null;
    try {    
        throw new CustomException()
    }catch (CustomException e) {
       //it work here
        throw e;
    } 

    return obj;

  }

 }
}

method call:

 try{
      Res resp = HttpProxy.getProxy(IMODEL.class).login();
  if (res != null){
      return ok;
  }
  }  catch (CustomException e) {
  //after set proguard.config ,its didn't work
  Log.e(TAG, Log.getStackTraceString(e));

 } catch(Exception e){
  //after set proguard.config ,its did here
  }

If I install project.properties, I cannot catch my own exception.

If I do not install project.properties, it works fine.

like obfuscation with proguard vs. java.lang.reflect.Proxy

+4
source share

Source: https://habr.com/ru/post/1569953/


All Articles