My query is related to bytecode manipulation using ASM.
I have one method as follows --
/*Original method code*/
String str ="abs";
// create object of SampleClass2 // constructor calling
SampleClass2 sample = new SampleClass2();
// call instance method
sample.PrintMe(str);
In the above method, I want to change the SampleClass2() constructor to one static method call which will return same SampleClass2 object after doing some logic. So after that my method will look something like this.
/*
* After bytecode manipulation*
*/
String str ="abs";
// get a constructor using static call
SampleClass2 sample = StaticClass.getSampleClass2Object();
sample.PrintMe(str);
Please tell me how can I achieve this using ASM bytecode manipulation. Do we need to change the existing bytecode stack for the same like DUP