1 Reply Latest reply on Jan 24, 2011 11:16 AM by sergio.celentano

    VerifyError, Bad type in putfield/putstatic

    sergio.celentano

      Hi guys,

      I am running into some problems while trying to use javassist facilities to implement a java fault injection tool.

       

      As an application (lets call it "worklaod") invokes a method from a third-party library, my tool should intercept this method, modify the parameters value on-the-fly and call the original method.

      Running through the tutorials provided with javassist library I found that the "sample/reflect/*.java" should suit my case and I took it into account as a starting point to implement my tool.

       

      So, following that tutorial, my "Injection" class extends the "javassist.tools.reflect.Metaobject" class and implement the "trapMethodCall()" method, in which I realize the arguments substitution.

      Another class (my.wrapper.Controller) implements the following snippet, in which "my.app.SubImpl" is the workload and "classNam" is the class whose methods I want to intercept:

       

              Loader cl = (Loader)my.app.SubImpl.class.getClassLoader();

              String className = "org.opensplice.dds.dcps.FooTypeSupportImpl";

              String metaObject = "my.wrapper.Injector";

              try {

                  cl.makeReflective(className,

                                    metaObject,

                                    "javassist.tools.reflect.Metaobject");

       

                  cl.run("my.app.SubImpl", args);

           ...


      The problem rises when I run my program with this statement "java javassist.tools.reflect.Loader my.wrapper.Controller", I get this error:

       

      java.lang.VerifyError: (class: org/opensplice/dds/dcps/FooTypeSupportImpl, method: <clinit> signature: ()V) Bad type in putfield/putstatic

       

      Furthermore I must say that the class "org.opensplice.dds.dcps.FooTypeSupportImpl" is an abstract class and methods I want to intercept are public and static and I am almost sure that this is the main cause of the issue. I wonder if there's any work-around for it.

       

      I hope my explanation was enough clear, any advice is appreciated =)

      Thank in advance,

       

      Sergio

        • 1. VerifyError, Bad type in putfield/putstatic
          sergio.celentano

          hi guys,

          I realized that i made some mistake in the snippet provided in the last report. First the getClassLoader() method should be called on the same class where the snippet has been included (my.wrapper.Controller). Then the metaclass argument in makeReflective() invocation should be javassist.tools.reflect.ClassMetaobject.

          Doing this way I can intercept the methods of any class but not of abstract classes, which is my case. Nobody knows how I can make this!?

           

          Thanks again,

           

          Sergio