Questions tagged [java-assist]

19 questions
0
votes
0 answers

Javassist.CannotCompileException when trying to create method with String and Object array as input parameters

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[] {…
javaseeker
  • 73
  • 1
  • 9
0
votes
1 answer

I have added a predefined annotation to a method at runtime, I want the changes to be permanent?

So, lets say I have a class Person and i want to add Myntra annotation to getLastName() method at runtime (which I have accomplished using Javassist library ) But I want the changes to be permanent so that when I run it next time the annotation…
Aditya Verma
  • 428
  • 6
  • 22
0
votes
4 answers

How to decorate an existing Java object's method?

EDIT: I've described our solution at https://stackoverflow.com/a/60235242/3236516 I have a java object. It is an instance of one of many subclasses that extend an abstract class. I would like to modify one of its methods such that it runs some…
0
votes
1 answer

Changing code with javassist has no effect (MethodCall)

I have this simple function: public int id() { return 0; } I have this test function: void test() { int a = id(); int b = id(); int c = id(); int d = id(); int e = id(); int f = id(); System.out.println(a+" "+b+"…
clankill3r
  • 9,146
  • 20
  • 70
  • 126
1
2