Questions on jvm interpreter

Dmitry Samersoff Dmitry.Samersoff at oracle.com
Thu Mar 29 22:44:39 PDT 2012


Saravanaraj,

I would recommend method below:
  1. Add a static method to your class.
     Use value returned by this method to drive all conditions.
  2. Use ASM library to change body of this static method as necessary
     in runtime.

-Dmitry


On 2012-03-29 20:48, Remi Forax wrote:
> Take a look to java.lang.instrument that allow you to alter the bytecode
> using by example ASM at runtime.
> 
> Cheers,
> Rémi
> 
> Sent from my Phone
> 
> ----- Reply message -----
> From: "Saravanaraj Velusamy" <svelusa at ncsu.edu>
> To: <distro-pkg-dev at openjdk.java.net>,
> <hotspot-compiler-dev at openjdk.java.net>
> Subject: Questions on jvm interpreter
> Date: Thu, Mar 29, 2012 10:20
> 
> 
> Hi All,
> 
> We are trying to alter the branch conditions taken by a java program at
> run time.
> 
> For example if a Java code has conditions like this
> 
> if( var == value1) 
>     PATH1;
> else
>     PATH2;
> 
> Lets say we want to it take PATH2 (even though var might be equal to
> value1). We might not change all branch statements in the class file and
> we can assume there is another source (say a text file) which contains
> what conditions needs to be changed.
> 
> We have two ideas to do the same.
> 1) To change the bytecode at that point during execution (like changing
> if_icmpeq to if_icmpne)
> 2) Find the place which contains the result of the first comparison and
> complement the result of the comparison.
> 
> The example has a simple conditional statement. We would also want to
> consider loops, switch cases later.
> 
> We would like to know what is the best way to go about and pointers in
> the code related to this. We are currently looking into
> bytecodeInterpreter.cpp of Zero instead of hotspot to avoid generated
> assembly for interpreter.
> Is there any way to find out the class file belonging to the current
> opcode ? Since we are not interested in the standard Java class files
> like String, Integer etc and focus on the ones from the User written
> classes and methods.
> 
> We have looked into BCEL, ASM, JVMTI and found out that we cannot change
> the behavior at run time.
> 
> Thanks in advance.
> - Saravanaraj


-- 
Dmitry Samersoff
Java Hotspot development team, SPB04
* There will come soft rains ...


More information about the hotspot-compiler-dev mailing list