This content has been marked as final.
Show 2 replies
-
1. Re: Accessing a parameter in a method's body
nadz Jun 17, 2005 7:46 AM (in response to nadz)For example i have the class :
public class Test1 { static int res; public static void main(String[] args) { foo (2); } public static int foo(int num) { res = num + 2; return res; } }
I want to get the parameter value of foo (here '2') and the returned value (here '4') and then transform the class by adding it 2 fields with these values like this :public class Test1 { static int res; static int paramValue = 2; static int returnValue = 4; public static void main(String[] args) { foo (2); } public static int foo(int num) { res = num + 2; return res; } }
Is there a way to perform this with Javassist ?
Many thanks for any help ! -
2. Re: Accessing a parameter in a method's body
chiba Jun 20, 2005 2:45 PM (in response to nadz)paramValue and returnValue are determined at runtime.
Since those values are not available during compile/load time,
you cannot obtain them by Javassist.
Although those values can be guessed by performaing
constant propagation since they are constant values,
Javassist does not support it.