Yes, there are many different ways to write code to do the same thing, and
smartbytecode is not supposed to find all in one pass. Multiple passes is
needed, and if planned carefully most cases can be found... Works fine for me
at least.. :)
chiba wrote : I see. Your approach is right.
chiba wrote : Ah... the statements must be surrounded by {}.
| So
|
| setBody({ System.out.println(...); ...println(...); });
|
| is correct. I agree this spec. should be changed. :-(
Ah, I see, it works now. Thanks for the reply :)
View the original post :
chiba wrote : I think you want to replace cascaded method calls
| with another expression.
|
| But I'm wondering whether or not such replacement
| is used frequently enough to be included in the Javassist
| API. Do you think the Javassist API includes a method
| for replacing
I need to find and replace all instances of
if(Display.getDisplay(this).getCurrent()==null)
| {
| ...
| }
in a given class, with
if (_getCurrent()==null)
| {
| ...
| }
_getCurrent() is a local method in the same class.
Sounds easy, but I have found no way to do this in Javassist so
I am modifying an existing constructor
| CtConstructor constructor=cc.getConstructors()[0];
| constructor.setBody(System.out.println(\hello1\);
System.out.println(\hello2\); );
|
But for some reason, only the first statement is added (I double checked by
decompiling the class), and