You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by Wassim Masri <wm...@aub.edu.lb> on 2006/05/29 21:33:41 UTC

Is there a way to uniquely identify a local variable in BCEL?

Dear All,

Is there a way to uniquely identify a local variable in BCEL?

For instance, in the example below both of the variables x2 and x3 have an index
equal to 2. So, we cannot rely on the index alone.

static void foo( )
{
	int x1= 0;
	if (x1 >= 0)
	{
		int x2 = 0;
	}

int x3 = 0;
}

I looked into using the scope (LocalVariableGen.getStart() and 
LocalVariableGen.getEnd()) in addition to the index, but there does not seem to
be a way to get this information from LocalVariableInstruction.

In a related (but less critical) matter, it seems that the scope information is
only accessible when I compile the target code with the ‘-g’ switch on.

Your help is really appreciated.

Wes





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


Re: Is there a way to uniquely identify a local variable in BCEL?

Posted by Dave Brosius <db...@apache.org>.
In class LocalVariableTable
public final LocalVariable getLocalVariable( int index, int pc )

will return the localvariable at the pc specified. This is new to 5.2

And yes -g is required.


----- Original Message ----- 
From: "Wassim Masri" <wm...@aub.edu.lb>
To: <bc...@jakarta.apache.org>
Sent: Monday, May 29, 2006 3:33 PM
Subject: Is there a way to uniquely identify a local variable in BCEL?


> Dear All,
>
> Is there a way to uniquely identify a local variable in BCEL?
>
> For instance, in the example below both of the variables x2 and x3 have an 
> index
> equal to 2. So, we cannot rely on the index alone.
>
> static void foo( )
> {
> int x1= 0;
> if (x1 >= 0)
> {
> int x2 = 0;
> }
>
> int x3 = 0;
> }
>
> I looked into using the scope (LocalVariableGen.getStart() and
> LocalVariableGen.getEnd()) in addition to the index, but there does not 
> seem to
> be a way to get this information from LocalVariableInstruction.
>
> In a related (but less critical) matter, it seems that the scope 
> information is
> only accessible when I compile the target code with the '-g' switch on.
>
> Your help is really appreciated.
>
> Wes
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: bcel-user-help@jakarta.apache.org
>
> 


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