2 Replies Latest reply on Feb 20, 2005 8:32 AM by carsten r


    carsten r Newbie


      i have discovered a strange behaviour.
      I tried to instrument methods of a class and somehow i get after
      the instrumentation, which seemed to work an Error.

      When i try to use the changed class in its old "enviroment",
      i get an exception/error by the verify, which says, that
      the given stack size of the method is not correct!

      Could it be, that javassist has under special condition problem
      to copy Methods? I am using the simple CtNewMethod mechanism
      to get a duplicate of a method an to rename the old method.


        • 1. Re: Copy-Method
          carsten r Newbie

          Hmm ... i should be more precise with this "question".

          Here is the code fragment of the class i am instrumenting.

          public void putNewEntry(Object key, SimpleEntry entry)
          throws AlreadyContainedException{

          This method simply inserts an new key-value pair into an Hashtable of
          my class. If the key-value pair is already in the hashtable i throw an
          exception. Its probably important that the second parameter is an interface. This interface also inherits from serializable, so that this
          types of objects can be stored.

          Now i am simply copying this method with the help of Javassist and
          rename it like this:

           public void copyMethod(CtClass clazz, CtMethod method){
           String mname = method.getName();
           String nname = mname + ComponentInstrumentor.mAPPENDIX;
           CtMethod mnew = CtNewMethod.copy(method, mname, clazz, null);

          Anyone a clue why i am getting such an error:

          java.lang.VerifyError: class ... copyMethod signature: (Ljava/lang/Object;LsimpleDB/SimpleEntry;)V (inconsitent stack height 0 != 2

          • 2. Re: Copy-Method
            carsten r Newbie

            Ok ... wrong question or better the Exception is caused by sth else
            than then a wrong copy operation.

            I am also redirecting internal method calls and there somehow
            is an error. So best remove this post ... thanx