Last night I was doing some refactoring to change the AInsertBeforeOpcodeStrategy
into a more general strategy that can insert both before and after an opcode, based on four predicates that determine whether the class should be instrumented (1), whether the method in the class should be instrumented (2), and finally whether code should be inserted before (3) and after (4) a particular opcode in the method.
When I ran my tests, I noticed that recording wasn’t working anymore. I tracked it down to my use of the java.util.Random
class in SyncPointBuffer
. Somehow I’m not allowed to reference it there, or that early in the VM initialization. Using Math.random()
, however, is ok. I find that weird: I just don’t really see the difference. The java.lang.Math
class has a static Random
field, just like my class did.
This is going to make it harder to display the seed and set the same seed again for future runs. Maybe I can somehow put it in a different class. Strictly speaking, the delayed execution stuff doesn’t have much to do with a “sync point buffer” anyway, and I only put the methods in the SyncPointBuffer
class for convenience.