Could the extend method be failing because it does not return a value? On Feb 19, 2008 9:31 AM, Robin Helgelin <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to do a simple prefix and extend to a single method, > however, it seems that ClassTransformation.extendMethod(), doesn't > find variables declared with prefixMethod(). > > Simple example which throws a javassist.CannotCompileException: > > transformation.prefixMethod(method, "int i = 1;"); > transformation.extendMethod(method, "i += 1;"); > > I also tried expanding the method by wrapping it, but that seems to > break @Persist:et members. I attach my attempt. It seems the problem > is that Tapestry only scans the new method, not the old one copied, am > I correct? > > public void renameAndExtendMethod(TransformMethodSignature > methodSignature, String newMethodName, String methodBody) > { > failIfFrozen(); > > CtMethod methodOld = findMethod(methodSignature); > methodOld.setName(newMethodName); > > CtMethod methodNew; > try > { > methodNew = CtNewMethod.copy(methodOld, > methodSignature.getMethodName(), > _ctClass, > null); > methodNew.setBody(methodBody); > _ctClass.addMethod(methodNew); > } > catch (CannotCompileException ex) > { > throw new > MethodCompileException(ServicesMessages.methodCompileError( > methodSignature, > methodBody, > ex), methodBody, ex); > } > > addMethodToDescription("renameAndExtend", methodSignature, > methodBody); > _addedMethods.add(methodOld); > } > > -- > regards, > Robin > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
-- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]