0 Replies Latest reply on Jul 28, 2011 6:30 AM by taggat4023

    VerifyError on auto generated code

    taggat4023

      I have a code generator that wraps a set of pojo's. I have been running it using the tools library successfully compiling the java previously.

       

      In the latest version i have changed to javaassist 3.15.0.GA and now my unit tests are constantly failing to run with a VerifyError

       

      I can get around it by commenting out 1 line of code, but this line of code is important to the flow of the application.

       

      The following code will generate a VerifyError (this is extracted from what i add into the classpool and ctclass structures)

       

      import javax.servlet.http;

      import uk.co.taylorconsulting.annoweb.web.exception;

      import uk.co.taylorconsulting.annoweb.web.cache;

      import uk.co.taylorconsulting.annoweb.web.interfaces;

      import uk.co.taylorconsulting.annoweb.web.enums;

      import org.apache.log4j;

      import java.lang;

      import uk.co.taylorconsulting.annoweb.annotation.action;

      import uk.co.taylorconsulting.annoweb.annotation.cache;

      import uk.co.taylorconsulting.annoweb.annotation.form;

      import uk.co.taylorconsulting.annoweb.annotation.form.validation;

      import uk.co.taylorconsulting.annoweb.annotation.injection;

      import uk.co.taylorconsulting.annoweb.annotation.security;

      import uk.co.taylorconsulting.annoweb.annotation.web;

      import uk.co.taylorconsulting.annoweb.builder.exception;

      import uk.co.taylorconsulting.annoweb.builder.structure;

      import uk.co.taylorconsulting.annoweb.builder.structure.form;

      import uk.co.taylorconsulting.annoweb.builder.structure.helper;

      import uk.co.taylorconsulting.annoweb.builder.structure.security;

      import uk.co.taylorconsulting.annoweb.builder.structure.view;

      import uk.co.taylorconsulting.annoweb.builder.structure.view.method;

      import uk.co.taylorconsulting.annoweb.builder.structure.view.parameter;

      import uk.co.taylorconsulting.annoweb.builder.util;

      import uk.co.taylorconsulting.annoweb.options;

      import uk.co.taylorconsulting.annoweb.web.cache;

      import uk.co.taylorconsulting.annoweb.web.controller;

      import uk.co.taylorconsulting.annoweb.web.enums;

      import uk.co.taylorconsulting.annoweb.web.exception;

      import uk.co.taylorconsulting.annoweb.web.interfaces;

       

       

      public uk.co.taylorconsulting.annoweb.site.siteName.root.base.View extends uk.co.taylorconsulting.annoweb.web.controller.WebHelper implements uk.co.taylorconsulting.annoweb.web.interfaces.ViewProcessor{

      private static final Logger LOG = Logger.getLogger(uk.co.taylorconsulting.annoweb.site.siteName.root.base.View.class

       

       

      public View(){}

      public process(HttpServletRequest request, HttpServletResponse response)

      {if($1.getParameter("dispatch") != null) {LOG.debug("dispatch=dispatch value=" + $1.getParameter("dispatch"));dispatchDispatch($1,$2);}}

       

       

      public dispatchDispatch(HttpServletRequest request, HttpServletResponse response)

      {String val = $1.getParameter("dispatch");LOG.debug("Dispatching for dispatch value=\"" + val + "\"");if(val.equals("login")) {processDispatchLogin($1,$2);} else if(val.equals("actionWithTestObject")) {processDispatchActionWithTestObject($1,$2);} else if(val.equals("notAuthed")) {processDispatchNotAuthed($1,$2);}}

       

       

      public processDispatchActionWithTestObject(HttpServletRequest request, HttpServletResponse response)

      {LOG.debug("AS:processing processDispatchActionWithTestObject");try {ATestObject var0 = null;try{var0 = $1.getParameter("a");} catch (Exception e){}if (var0==null) {try{var0 = (uk.co.taylorconsulting.annoweb.builder.structure.samples.ATestObject)$1.getAttribute("a");} catch (Exception e){}}uk.co.taylorconsulting.annoweb.builder.structure.samples.StructureTestBasic action=(uk.co.taylorconsulting.annoweb.builder.structure.samples.StructureTestBasic)Cache.getClassCache("uk.co.taylorconsulting.annoweb.builder.structure.samples.StructureTestBasic");action.actionWithTestObject(var0);LOG.warn("No default forwards have been defined");} catch (Exception e) {LOG.warn("An error has occured in the action processDispatchActionWithTestObject Exception: " + e.getClass().getCanonicalName() +"(" + e.getMessage() +")");}}

       

       

      public processDispatchNotAuthed(HttpServletRequest request, HttpServletResponse response)

      {LOG.debug("AS:processing processDispatchNotAuthed");try {uk.co.taylorconsulting.annoweb.builder.structure.samples.StructureTestBasic action=(uk.co.taylorconsulting.annoweb.builder.structure.samples.StructureTestBasic)Cache.getClassCache("uk.co.taylorconsulting.annoweb.builder.structure.samples.StructureTestBasic");action.notAuthorised();LOG.warn("No default forwards have been defined");} catch (Exception e) {LOG.warn("An error has occured in the action processDispatchNotAuthed Exception: " + e.getClass().getCanonicalName() +"(" + e.getMessage() +")");}}

       

       

      public processDispatchLogin(HttpServletRequest request, HttpServletResponse response)

      {LOG.debug("AS:processing processDispatchLogin");try {uk.co.taylorconsulting.annoweb.builder.structure.samples.StructureTestBasic action=(uk.co.taylorconsulting.annoweb.builder.structure.samples.StructureTestBasic)Cache.getClassCache("uk.co.taylorconsulting.annoweb.builder.structure.samples.StructureTestBasic");action.login();LOG.warn("No default forwards have been defined");} catch (Exception e) {LOG.warn("An error has occured in the action processDispatchLogin Exception: " + e.getClass().getCanonicalName() +"(" + e.getMessage() +")");}}

      }

       

      If i put this into a java file and compile it, it is fine and even the javaassist compiile does not complain about the code.

       

      If i remove the ATestObject from the processDispatchActionWithTestObject method's call to action.actionWithTestObject(var0); and replace it with action.actionWithTestObject(null); then this works successfully and doesn't complain, but then as you could imagine breaks the required data.

       

      Can you tell me what i can do to get around this issue. this is the generated code from a unit test that i can get to fail every time (and get to pass by changing the data as mentioned above)

       

      I have attached 2 files of the full java code generated from the unit test one that works and one that doesn't (another way of getting it to work is to remove other code which i also need)