0

I need to create a method using JavaAssist CtMethod. This method need to accept a String and an array of objects as input parameters as below

String methodBody = "$1.look(\"" + (lname).replace("\"", "").trim() + "\"" + " ," + new Object[] { lp.get(0) }+ ")";

where lp is List

but when i create the method I get exception:

javassist.CannotCompileException: [source error] syntax error near "String" ,[Ljava.lang"

Any idea why this exception is thrown from javaassist?

I actually want to pass the entire lp object as parameter into the method, but in the above code,I was trying to see if JavaAssist will accept if I pass just one entry in the list like

new Object[] { lp.get(0) }

Any idea why this exception is thrown from javaassist?

javaseeker
  • 73
  • 1
  • 9
  • You're not calling a method,just building a string, also the error seems to come near `String` word, what are the lines before ? – azro Mar 21 '20 at 09:19
  • What is the content of `methodBody` after all the values are expanded? – k5_ Mar 25 '20 at 13:00

0 Answers0