-
1. Re: How to modify this statement with Javaassist?
chiba Jan 12, 2005 12:31 PM (in response to panzer_kavalier)You can use ExprEditor for replacing getResourceAsStream("/file") with
{ $_ = MyUtil.getResourceAsStream($0, $1); }
Then you can obtain the effects that you want. -
2. Re: How to modify this statement with Javaassist?
panzer_kavalier Jan 12, 2005 8:21 PM (in response to panzer_kavalier)thanks a lot.
but when I use ExprEditor for replace this statement, how can I find the statement first. because the statement has so many forms. -
3. Re: How to modify this statement with Javaassist?
chiba Jan 12, 2005 9:53 PM (in response to panzer_kavalier)Doesn't finding a method call to getResourceAsStream()
work? -
4. Re: How to modify this statement with Javaassist?
panzer_kavalier Jan 12, 2005 10:09 PM (in response to panzer_kavalier)I used the CtClass.getMethods for finding the getResourceAsStream() method, Unfortunately, the getResourceAsStream() method was not found in my test class file. because the getResourceAsStream() method is not the method declared in my class file, it's called by the java/lang/class.
My test code:
public class TestGetRes{
public void load(){
DataInputStream dis = new DataInputStream(getClass().getResourceAsStream("/file"));
}
}
I can use the getMethod() method for finding the load() method, but I don't know how to fine the getResourceAsStream() method, so I can't use the ExprEditor to repalce this method.
the result expects after the correct replacement:
public class TestGetRes{
public void load(){
DataInputStream dis = new DataInputStream(MyUtil.getResourceAsStream(getClass(), "/file"));
}
}
thanks a lot.
online waiting. -
5. Re: How to modify this statement with Javaassist?
panzer_kavalier Jan 13, 2005 2:19 AM (in response to panzer_kavalier)thanks to chiba, I got the result expected.