2009/11/2 MUTHURAMAN SWAMINADHAN <muthu...@yahoo.com>:
> I have been trying to get the local variables in a method but I don't see 
> anything returned. I am using the following snippet.
>
> LocalVariable lv[];
> LocalVariableTable lvt;
> lvt=mt.getLocalVariableTable(); //mt is a method  object
> lv=lvt.getLocalVariableTable();
>
> I don't get anything back in the lv array. Can anyone advise if this is the 
> correct approach or if there is a better approach?

The local variable table is an optional table in the class file.
Unless you compile with the debug option (which, by default, includes
the local variables, line numbers, and location of the original
source), it will be missing.  Try "javac -g" to compile.

See the Java VM specification for more details:

  
http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#5956

You can also use javap to have a look at the local variable table (to
see if it is there in the file):

  javap -verbose MyClass

I hope that helps.

Kind regards,
Matthew

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

Reply via email to