edu.rice.cs.cunit.instrumentors
Class SynchronizedMethodToBlockStrategy

java.lang.Object
  extended by edu.rice.cs.cunit.instrumentors.SynchronizedMethodToBlockStrategy
All Implemented Interfaces:
IInstrumentationStrategy

public class SynchronizedMethodToBlockStrategy
extends java.lang.Object
implements IInstrumentationStrategy

Instrumentor that turns a synchronized methods into an unsynchronized method with a synchronized block.

NOTE: This instrumentation strategy has to be run before SynchronizedBlockStrategy.

Author:
Mathias Ricken

Field Summary
protected  java.util.ArrayList<MethodInfo> _newMethods
          Methods to add.
 
Constructor Summary
SynchronizedMethodToBlockStrategy()
          Constructor.
 
Method Summary
 void done()
          Instrumentation of all classes is done.
 void instrument(ClassFile cf)
          Instrument the class.
protected  void instrumentSynchronizedMethod(ClassFile cf, MethodInfo mi, byte[] loadLockCode, int reqdStackSize)
          Instrument a synchronized method's code blocks.
protected  void instrumentSynchronizedMethods(ClassFile cf)
          Instrument synchronized methods in this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_newMethods

protected java.util.ArrayList<MethodInfo> _newMethods
Methods to add.

Constructor Detail

SynchronizedMethodToBlockStrategy

public SynchronizedMethodToBlockStrategy()
Constructor.

Method Detail

instrument

public void instrument(ClassFile cf)
Instrument the class.

Specified by:
instrument in interface IInstrumentationStrategy
Parameters:
cf - class file info

instrumentSynchronizedMethods

protected void instrumentSynchronizedMethods(ClassFile cf)
Instrument synchronized methods in this class. Inside a non-native synchronized method, a synchronized block around the entire code is added, and the method is changed to unsynchronized.

Parameters:
cf - class file info

instrumentSynchronizedMethod

protected void instrumentSynchronizedMethod(ClassFile cf,
                                            MethodInfo mi,
                                            byte[] loadLockCode,
                                            int reqdStackSize)
Instrument a synchronized method's code blocks. This turns any method synchronized T method(T t...) { abc(); } into T method(T t...) { synchronized (?) { abc(); } }

Parameters:
cf - class file
mi - method info
loadLockCode - instructions to load the object that gets locked
reqdStackSize - required state size

done

public void done()
Instrumentation of all classes is done.

Specified by:
done in interface IInstrumentationStrategy