4 Replies Latest reply on Nov 15, 2005 12:01 PM by dominik_fhg

    Problem with java.lang.VerifyError

    bspies

      Hi all,

      I'm working on code that dynamically parses input records based on XML configuration...I'm having a problem with a thrown java.lang.VerifyError from Class newInstance() after calling CtClass.toClass(). The error is this:

      java.lang.VerifyError: (class: com/sbc/bac/load/cebav/account/DailyAccountLineBeanXCRS5011Record, method: parseLine signature: (Ljava/lang/String;)Ljava/lang/Object;) Register 3 contains wrong type
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
      at java.lang.Class.getConstructor0(Unknown Source)
      at java.lang.Class.newInstance0(Unknown Source)
      at java.lang.Class.newInstance(Unknown Source)
      at com.sbc.bac.load.records.DynamicFileParserFactory.generateDynamicRecord(DynamicFileParserFactory.java:110)

      The Record interface that this class extends just defines 1 method:
      public Object parseLine(String line);

      There is an abstract 'glue class' that implements Record here--all this does
      is have an empty parseLine() method, a getSeparator(), and two protected HashMap's. I am replacing the body of the parseLine() method with the code:

      {
      String curToken;
      java.text.DateFormat df;
      java.util.StringTokenizer st = new java.util.StringTokenizer($1, getSeparator());
      com.sbc.bac.load.cebav.account.DailyAccountLineBean bean = (com.sbc.bac.load.cebav.account.DailyAccountLineBean)newBean();

      if(!st.hasMoreTokens())
      throw new com.sbc.bac.load.error.RecordException("Number of input records is less than configured records.");

      curToken = st.nextToken();
      curToken = curToken.trim();
      if(!curToken.equals(""))
      bean.setDivision(curToken);

      //etc...

      if((df = (java.text.DateFormat)dateCache.get("yyyyMMdd"))==null)
      dateCache.put("yyyyMMdd", df = new java.text.SimpleDateFormat("yyyyMMdd"));
      bean.setProcessDate(new java.sql.Date(df.parse(curToken).getTime()));

      //etc...
      }

      Does anybody have an idea of what could be happening here? If I write out a class file from CtClass, then decompile it with JAD, the code compiles on Eclipse just fine.

        • 1. Re: Problem with java.lang.VerifyError
          chiba

          You can dump by calling writeFile() in CtClass.
          Can you put the class file on some web site or anywhere
          you can put? I'll check it.

          Note: please don't trust a decompiler too much.
          It cannot decompile some correct class file in principle.

          • 2. Re: Problem with java.lang.VerifyError
            bspies

            Chiba,

            I don't really have access to a site I can post the file, so I've emailed you the file instead (hope you don't mind).

            Thanks,

            Brennan

            • 3. Re: Problem with java.lang.VerifyError
              chiba

              Brennan and I investigated this problem and found that
              the real problem was the value of the variable df declared in this
              statement:

              java.text.DateFormat df;

              was used before the initial value is assigned to this variable.

              Javac can detect this type of error is detected but the compiler
              of Javassist does not. This is simply for better runtime performance.



              • 4. Re: Problem with java.lang.VerifyError
                dominik_fhg

                Hi,

                i solved this Problem by:

                Loader loader = new Loader(pool2);
                
                 loader.delegateLoadingOf("packageTestA.SuperClass");