Hi All, Problem with local variables

"Koduru, Rajendra Kumar Reddy" <[email protected]>
Newsgroups gmane.comp.jakarta.bcel.user
Message-ID <[email protected]>
Hi All,

   I have problem with local variables.

	My intention is to insert a statement 

	Object param = methodA(this) at the start of method

	And

	methodB(param, "message") at the end of method

I am using try-finally because i need to jump to finally before each
return statement.


	I could not understand clearly the concept of local variables
here 

What i am doing is 

   I am creating a local variable "param"
   setting the index of this variable to "1" using localVar.setIndex(1)

  and retreiving it by using new ALOAD(1)

  As i am using try-finally, i should catch and rethrow the exception

	so i am storing the exception in localvar 2 in handler
	new ASTORE(2), 
	
	and retreiving it back by new ALOAD(2), before rethrowing it.

 
  And I am sotirng the return address in localvar 3 


And the method is modified, when I tried to open it with jad, I cant see
the method , a message is displayed  as following

// JavaClassFileOutputException: get_local_var: index out of range

I treid to find the set of isntructions of this method using javap - c
option, I got the following , which seems to be correct for me

   0:	aload_0
   1:	invokestatic	#986; //Method
methodA:(Ljava/lang/Object;)Ljava/lang/Object;
   4:	astore_1
   5:	getstatic	#989; //Field
java/lang/System.out:Ljava/io/PrintStream;
   8:	ldc_w	#1006; //String method call : getCurrentLogonUser
   11:	invokevirtual	#996; //Method
java/io/PrintStream.println:(Ljava/lang/String;)V
   14:	aload_0
   15:	getfield	#584; //Field
currentUser:Lcom/sap/ip/me/core/UserImpl;
   18:	areturn
   19:	astore_2
   20:	jsr	25
   23:	aload_2
   24:	athrow
   25:	astore_3
   26:	getstatic	#989; //Field
java/lang/System.out:Ljava/io/PrintStream;
   29:	ldc_w	#1008; //String method exit : getCurrentLogonUser
   32:	invokevirtual	#996; //Method
java/io/PrintStream.println:(Ljava/lang/String;)V
   35:	aload_1
   36:	ldc_w	#1008; //String method exit : getCurrentLogonUser
   39:	invokestatic	#1002; //Method
methodB:(Ljava/lang/Object;Ljava/lang/String;)V
   42:	ret	3
  Exception table:
   from   to  target type
    14    19    19   any


Could you please let me know, where I am wrong.. Is it problem with
decompiler??

Cant I set the index of local variables as I like???

Please help me in this regard...

Thank you 
Reddy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.