edu.ucsb.ccs.jcontractor.transformation
Class LockCloneTransformation

java.lang.Object
  |
  +--edu.ucsb.ccs.jcontractor.transformation.Transformation
        |
        +--edu.ucsb.ccs.jcontractor.transformation.ContractTransformation
              |
              +--edu.ucsb.ccs.jcontractor.transformation.LockCloneTransformation

public class LockCloneTransformation
extends ContractTransformation

Transformation to disable contract checking while in the clone() method. clone() is used to implement OLD references, and checking contracts on method called from clone() could require more calls to clone(). This leads to infinite recursion, which would be bad. To prevent this scenario, jContractor does not check contracts on any methods called from clone().

Note: Strictly speaking, all that is required is to not check contracts that refer to OLD. However, just supressing all contract checks is much easier to implement.

Version:
$Id: LockCloneTransformation.java,v 1.4 2002/07/11 19:42:45 parkera Exp $
Author:
Parker Abercrombie

Constructor Summary
LockCloneTransformation()
           
 
Method Summary
 boolean acceptClass()
          Determine if the current class should be processed.
 void transformClass()
          Does nothing.
 void transformMethod(org.apache.bcel.generic.MethodGen mg)
          Add code to a clone() method that will suppress contract checks inside the method.
 
Methods inherited from class edu.ucsb.ccs.jcontractor.transformation.ContractTransformation
canCheckEntryInvariant, canCheckExitInvariant, canCheckPostcondition, canCheckPrecondition, canHaveInvariant, canHavePostcondition, canHavePrecondition, canReferenceOld, contractsCheckable, getContractClassName, getContractClassName, getInvariantMethodName, getInvariantMethodSignature, getPostconditionMethodName, getPostconditionMethodSignature, getPreconditionMethodName, getPreconditionMethodSignature, isContractClass, isContractMethod, isInvariantMethod, isPostconditionMethod, isPreconditionMethod
 
Methods inherited from class edu.ucsb.ccs.jcontractor.transformation.Transformation
getTransformer, setTransformer, transform
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockCloneTransformation

public LockCloneTransformation()
Method Detail

acceptClass

public boolean acceptClass()
Determine if the current class should be processed. All classes in which contracts are checkable are processed.

Overrides:
acceptClass in class Transformation
Returns:
true if contracts are checkable in the current class.

transformMethod

public void transformMethod(org.apache.bcel.generic.MethodGen mg)
Add code to a clone() method that will suppress contract checks inside the method. Has no effect if the method is not named "clone", with no arguments, and a Object return type.

Overrides:
transformMethod in class Transformation
Parameters:
mg - a method to transform. The method is transformed only if it is a has the signature "Object clone()".

transformClass

public void transformClass()
Does nothing. This transformation operates only on methods.

Overrides:
transformClass in class Transformation