jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yasir Siraj <yasir...@yahoo.com>
Subject Re: Retrieve all the values of variables in the class ?
Date Wed, 30 Jun 2004 07:56:37 GMT
Hello,
   To get all class variables & their values, u can
use this
Field fields[] = jClass.getFields();
	for (int i = 0; i < fields.length; i++) {
            fields[i].getName();
            fields[i].getConstantValue();
        }

For method variables, u can use 
MethodGen mGen = new MethodGen(method,
className,constantpoolgen );
mGen.getLocalVariables();

I hope this will help.

Regards.
Yasir Siraj.
IMP-DCS
Chalmers University Of Technology
Goteborg, Sweden.

--- Eric Chow <echow@macaucabletv.com> wrote:
> Hello,
> 
> How can I get the all variable values in the class
> including all the globale
> constant values and local variable values ??
> 
> For example,
> 
> public class A {
>    private static final String s = "Hello World";
> 
>    public int sum(int a, in b) {
>       int x = 100;
>       return a + b + x;
>    }
> }
> 
> 
> How can I get the value of "x" in the method sum and
> the value of String s
> ???
> 
> 
> Eric
> 
> 
> ==========================
> If you know what you are doing,
> it is not called RESEARCH!
> ==========================
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> bcel-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> bcel-user-help@jakarta.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org


Mime
View raw message