2 Replies Latest reply on Apr 26, 2006 9:58 PM by chiba

    Changing the Exception of MethodHandler to Throwable

    starksm64

      The exception throws clause of the javassist.util.proxy.MethodHandler.invoke method should really be a Throwable rather than an exception, otherwise the basic implementation of delegating to another object via reflection has to deal incon

      public class ThingMethodHandler implements MethodHandler
      {
       private IThing theThing;
       public ThingMethodHandler(IThing theThing)
       {
       this.theThing = theThing;
       }
      
       public Object invoke(Object self, Method thisMethod, Method proceed,
       Object[] argss)
       throws Exception
       {
       Object result = null;
       try
       {
       result = method.invoke(theThing, args);
       }
       catch (InvocationTargetException e)
       {
       Throwable t = e.getTargetException();
       // How to deal with throwing an Exception?
       }
      
       return result;
       }
      }
      
      


      The following iterface cannot be proxied correctly because of this as method1 and method2 will have to have their Throwable and Error wrapped in an Exception:

      public interface IThing
      {
       public void method1() throws Throwable;
       public void method2() throws Error;
      }