0 Replies Latest reply on Nov 18, 2012 3:57 AM by amitabakoptier

    javassist and interfaces defining a method which throws an exception question

    amitabakoptier

      A Question regarding the JVM spec and how javassist is expected to handle it.

      I’ve an interface IMyFactory extending the Remote interface.

      It declares a method foo() which declares throws RemoteException so will be deemed as remotable API

       

      The implementing class implements the method but doesn’t declare itself as throwing the remote.

      Code wise the JVM picked this method as valid Remote API

      Javassist when interrogated class MyFactory.foo() method doesn’t provide any data on its being a throwing RemoteException

       

      Questions

      1. The JVM spec defines a method by its name and properties, not by its exception throwing.

      In addition it allows an implementing method to declare less “throws” then its super / defining interface without loss of polymorphism

      1. e.g. this foo() implementer is deemed the same as in the interface.

       

      Why wont javassist provide me the exception data defined in the Interface’s CtClass ?

       

         2) Is there a “recoursive” API in javassist that will wllow me to intergoate a method up to its interface definition to see if some one above it has defined it to be an  

            Throwable thrower or do I need to implement such search myself ?

       

       

      Code example:

       

      1. 1. MyFactory implements IMyFactory

         {...

           @Override

           public int foo() //on purpose didn’t declare “throws java.rmi.RemoteException”

           {

             // TODO Auto-generated method stub

             return 0;

           }  

       

      1. 2. public interface IMyFactory extends Remote

         {

           public int foo() throws RemoteException;

         }