2011-04-26 5 views
0

나는 모든 가능한 인터페이스를 구현하는 일반적인 방법을 가지고 java.lang.reflect.Proxy 물건을 디버깅 이유로 사용하지만 ...이 어려운 것 같다 그것은 프로 가드와 함께 일하고 있습니다. 어떤 제안?proguard 대 java.lang.reflect.Proxy와 난독 화

THX -Marco

public class DebugLogListenerFactory { 

public static IAirplaneListenerAll createStreamHandle(ICAirplane plane) { 
    DebugLogListenerHandler handler = new DebugLogListenerHandler(plane); 
    IAirplaneListenerAll proxy = (IAirplaneListenerAll) Proxy 
      .newProxyInstance(IAirplaneListenerAll.class.getClassLoader(), 
        new Class[] { IAirplaneListenerAll.class }, handler); 

    plane.addListener(proxy); 
    return proxy; 
} 

private static class DebugLogListenerHandler implements InvocationHandler { 


    private final Level levDef = Level.FINE; 


    public DebugLogListenerHandler() { 
    } 

    public Object invoke(Object proxy, Method method, Object[] args) 
      throws Throwable { 
     System.out.println("invoked" + method); 
     String methodName = method.getName(); 
     String msg = methodName + ": "; 
     if (args != null) { 
      boolean first = true; 
      for (Object o : args) { 
       if (first) { 
        first = false; 
       } else { 
        msg += " ,"; 
       } 
       msg += o.toString(); 
      } 
     } 
     CDebug.getLog().log(levDef, msg); 
     return null; 
    } 
} 

}

답변

0

가장 쉬운 해결책은/축소 최적화/인터페이스 및 그 방법 난독 피하기 위해 아마 : 당신은 축소를 허용 할 수 있습니다

-keep interface some.package.IAirplaneListenerAll { 
    <methods>; 
} 

를 :

-keep,allowshrinking interface some.package.IAirplaneListenerAll { 
    <methods>; 
} 

InvocationHandler가 난독 화 메소드 이름을 처리 할 수있는 경우 난독 처리를 허용 할 수도 있습니다.

-keep,allowshrinking,allowobfuscation interface some.package.IAirplaneListenerAll { 
    <methods>; 
}