you could just use MethodGen.getMaxLocals() as a local variable number that is not used throughout the method. Make sure you keep getMaxLocals up to date by calling setMaxLocals when appropriate.

[EMAIL PROTECTED] wrote:
Hi,so I have been playing with BCEL for a couple of weeks now and it works
really nice, but I have the following problem:

Consider this java code:


void foo(int x) { String a = "aa"; [x] -> localvariables(0=x,1=a) so I need to use 2 and 3 somemethod();

  String b = "bb";
  [y] -> localvariables(0=x,1=a,2=b) so I need to use 3 and 4
  someOthermethod();
}

What I need to do is instrument some synchronized blocks around the methods,
but the thing is that synchronization code will need local variables to
store various values such as the actual monitor object and another for
exception handling to ensure that the monitor is released when something bad
happens. So in the end the code I am going to instrument 'around' something
needs 2 local variable spaces, but ofcourse I don't want to overwrite
anything. How can I do this nicely? It would be great if there would be a
method like getCurrentLocalVariableIndex that would return 1 at [x] and 2 at
[y] but I couldn't find such a thing in the API doc, but there should be
some nice solution to this so, any suggestions?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- "I say to you that the VCR is to the American film producer and the American public as the Boston strangler is to the woman home alone." -Jack Valenti, President, Motion Picture Association of America, Inc., before The House Subcommittee on Courts, Civil Liberties, and The Administration of Justice, August, 1982, http://cryptome.org/hrcw-hear.htm


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to