-
1. Re: Can I get info about containing object of some methodCal
chiba Jan 12, 2005 11:15 AM (in response to rezahay)ExprEditor tells you the static type of someObj but
it cannot show you the real value of someObj since
ExprEditor runs during compile time or load time;
the value of someObj is a runtime value, which does
not exist at compile time. -
2. Re: Can I get info about containing object of some methodCal
rezahay Feb 8, 2005 8:01 AM (in response to rezahay)You are absolutely right. I want actually static information about "someObj", like object-type, ... .
Would you please tell me how I can get this information?
Thanks -
3. Re: Can I get info about containing object of some methodCal
sirrurg Feb 15, 2005 2:05 AM (in response to rezahay)Hi,
simply have a look at the API oder better at the Tutorial too, there
i guess u can find everything u want.
The process of getting this info should be sth like this:
1) load class
2) get desired method
3) use your XYZExprEditor, which should inherit from from javassist.expr.ExprEditor
4) call CtMethod.instrument(XYZExprEditor) (of course in this case CtMethod should be an instance the method u want to look at)
5) within your XYZExprEditor, there is a Method edit(MethodCall ...)
which identifies an call to a method within a method body.
With this class MethodCall u can get the desired infos i guess.
Hopefully this info helped u a bit and i didnt make a mistake
Bye -
4. Re: Can I get info about containing object of some methodCal
rezahay Feb 17, 2005 5:24 AM (in response to rezahay)Hi,
Thank you for your response. But it doesn't solve my problem. As you can see from my previous mailing, I have already used ExprEditor to get information about "someMethod" in the following method-call expression:
..........................
someObj.someMethod
..........................
But I need information about "someObj". I need just static information like the name of "someObj", it type (class), ... .
The question is: How can I get such static information about "someObj" using javassist?
Thanks. -
5. Re: Can I get info about containing object of some methodCal
sirrurg Feb 17, 2005 12:56 PM (in response to rezahay)Hmmm ...
and sth like this doesnt solve ur problem?!?public void edit(MethodCall m) { CtClass c = m.getMethod().getClass(); c.getName(); .... }
-
6. Re: Can I get info about containing object of some methodCal
chiba Feb 23, 2005 8:27 AM (in response to rezahay)I hope my reply is not too late.
The question is: How can I get such static information about "someObj" using javassist?
The real static information of the target object is quite restricted
probably more than you expect. The only information is the static
type of the target object, which is the class declaring the method.
For example,
String s = "foo";
int s = s.concat("bar").length();
In this example, the target expression of length() is s.concat("bar")
and it does not have a name. The only static information is the type
of the target expression is String.