jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Bessi <bessima...@gmail.com>
Subject Same questions about variable names
Date Mon, 14 Jun 2010 11:12:46 GMT
Hi all,
I have same problem with bcel api, so I try to answere in this list.

1) How can I get the class variable name about the method that is invoked?
Explain: I have this example code.
String s = "hello";
String g = "world";
int i = s.lenght();
How can I retrieve the name of the variable where i call the method
lenght()? I want the variable name "s"!

Because if I lunch the command "javap -verbose ClassName" I obtain the
bytecode for the class ClassName and I can't get directly the name of
the class where the method is called. For the example code I can get
only that lenght() is a method of the class String but not the name of
the variable "s".

2) If I didn't compile the file class with "javac -g" I can't have the
LocalVariableTable, ok? But can I know if a variable is declarated
internally in the method or is a global variable of the class?
HashSet<String> argsVar = new HashSet<String>();			
String[] args = mg.getArgumentNames(); //mg is a MethodGen variable
int k = 0;
int nArgs = args.length;
while(k < nArgs){
	argsVar.add(args[k]);
        k++;
}

3) The bytecode instructions aload_0 refears always at: args if the
method is the main; this otherwise?

Sorry for my bad English.
Thanks for the attention.
Marco.

---------------------------------------------------------------------
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