|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--edu.ucsb.ccs.jcontractor.transformation.Transformation
|
+--edu.ucsb.ccs.jcontractor.transformation.ContractTransformation
Abstract super class for contract transformations. This class defines methods that determine the names and signatures of contract methods, and defines the rules about which methods may have which sorts of contracts, and when contracts are checked. Logic about the naming conventions used by jContractor, and about the rules of when contracts can be checked is encapsulated in this class.
This class also defines several utility methods that are useful for working with InstructionLists.
| Constructor Summary | |
ContractTransformation()
|
|
| Method Summary | |
boolean |
canCheckEntryInvariant(org.apache.bcel.generic.MethodGen mg)
Determine whether or not this method should have a invariant check at its entry point. |
boolean |
canCheckExitInvariant(org.apache.bcel.generic.MethodGen mg)
Determine whether or not this method should have a invariant check at its exit point. |
boolean |
canCheckPostcondition(org.apache.bcel.generic.MethodGen mg)
Determine whether or not this method should have a postcondition check. |
boolean |
canCheckPrecondition(org.apache.bcel.generic.MethodGen mg)
Determine whether or not this method should have a precondition check. |
boolean |
canHaveInvariant(org.apache.bcel.classfile.JavaClass javaclass)
Determine whether or not a class can have an invariant. |
boolean |
canHavePostcondition(org.apache.bcel.generic.MethodGen mg)
Determine whether or not this method can have a postcondition, taking instrumentation level into account. |
boolean |
canHavePrecondition(org.apache.bcel.generic.MethodGen mg)
Determine whether or not this method can have a precondition, taking instrumentation level into account. |
boolean |
canReferenceOld(org.apache.bcel.generic.MethodGen mg)
Determine if the postcondition for a non-contract method can refer to OLD. |
boolean |
contractsCheckable(org.apache.bcel.classfile.JavaClass javaclass)
Determine whether or not contracts should be checked on the methods in a class. |
java.lang.String |
getContractClassName(org.apache.bcel.classfile.JavaClass javaclass)
Get the name of the external contract class that cooresponds to the given class. |
java.lang.String |
getContractClassName(java.lang.String classname)
Get the name of the external contract class that cooresponds to the given class name. |
java.lang.String |
getInvariantMethodName(org.apache.bcel.classfile.JavaClass javaclass)
Get the name of the invariant method for a class. |
java.lang.String |
getInvariantMethodSignature(org.apache.bcel.classfile.JavaClass javaclass)
Get the signature of the invariant method for a class. |
java.lang.String |
getPostconditionMethodName(org.apache.bcel.generic.MethodGen m)
Get the name of the postcondition method for a non-contract method. |
java.lang.String |
getPostconditionMethodSignature(org.apache.bcel.generic.MethodGen m)
Get the signature of the method that defines the postcondition for a non-contract method. |
java.lang.String |
getPreconditionMethodName(org.apache.bcel.generic.MethodGen method)
Get the name of the precondition method for a non-contract method. |
java.lang.String |
getPreconditionMethodSignature(org.apache.bcel.generic.MethodGen m)
Get the signature of the method that defines the precondition for a non-contract method. |
boolean |
isContractClass(org.apache.bcel.classfile.JavaClass javaclass)
Determine if a class defines contracts for another class. |
boolean |
isContractMethod(org.apache.bcel.generic.MethodGen m)
Determine if a method defines a contract (precondition, postcondition, or invariant). |
boolean |
isInvariantMethod(org.apache.bcel.generic.MethodGen m)
Determine if a method defines a class invariant. |
boolean |
isPostconditionMethod(org.apache.bcel.generic.MethodGen m)
Determine if a method defines a postcondition. |
boolean |
isPreconditionMethod(org.apache.bcel.generic.MethodGen m)
Determine if a method defines a precondition. |
| 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 |
public ContractTransformation()
| Method Detail |
public boolean canHavePrecondition(org.apache.bcel.generic.MethodGen mg)
main (String args) method.
canCheckPrecondition(MethodGen) answers the
checkabilty question.
InstrumentationFilter,
canCheckPrecondition(MethodGen)public boolean canHavePostcondition(org.apache.bcel.generic.MethodGen mg)
canCheckPostcondition(MethodGen) answers the
checkabilty question.
InstrumentationFilter,
canCheckPostcondition(MethodGen)public boolean canHaveInvariant(org.apache.bcel.classfile.JavaClass javaclass)
javaclass - a class to test.
InstrumentationFilter,
canCheckExitInvariant(MethodGen),
canCheckEntryInvariant(MethodGen)public boolean contractsCheckable(org.apache.bcel.classfile.JavaClass javaclass)
javaclass - a class to check.
javaclass (ie true if javaclass
is not a contract class).isContractClass(JavaClass)public boolean canCheckPrecondition(org.apache.bcel.generic.MethodGen mg)
canHavePrecondition(MethodGen)public boolean canCheckPostcondition(org.apache.bcel.generic.MethodGen mg)
canHavePostcondition(MethodGen)public boolean canCheckEntryInvariant(org.apache.bcel.generic.MethodGen mg)
canCheckExitInvariant(MethodGen)public boolean canCheckExitInvariant(org.apache.bcel.generic.MethodGen mg)
canCheckEntryInvariant(MethodGen)public boolean canReferenceOld(org.apache.bcel.generic.MethodGen mg)
clone().*
clone()
to make a copy of the object. Given this implementation,
clone() itself if unable to refer to the old state.
mg - a non-contract method to examine.
m's postcondition is allowed to
refer to OLD. False if the postcondition is not allowed
to refer to OLD, or if the postcondition is not
checkable.public boolean isContractClass(org.apache.bcel.classfile.JavaClass javaclass)
javaclass - a class to test.
javaclass is a contract class.public boolean isContractMethod(org.apache.bcel.generic.MethodGen m)
m - a method to test.
m defines a contract.isPreconditionMethod(MethodGen),
isPostconditionMethod(MethodGen),
isInvariantMethod(MethodGen)public boolean isPreconditionMethod(org.apache.bcel.generic.MethodGen m)
m - a method to test.
m defines a precondition
(m's name ends with "_Precondition").public boolean isPostconditionMethod(org.apache.bcel.generic.MethodGen m)
m - a method to test.
m defines a postcondition
(m's name ends with "_Postcondition").public boolean isInvariantMethod(org.apache.bcel.generic.MethodGen m)
m - a method to test.
m defines a class invariant
(m's name is "_Invariant").isInvariantMethod(MethodGen)public java.lang.String getPreconditionMethodName(org.apache.bcel.generic.MethodGen method)
Examples:
public class MyClass () {
MyClass () { ... }
boolean MyClass_Precondition () { ... }
void foo () { ... }
boolean foo_Precondition () { ... }
}
method - a non-contract method. The name of the
precondition method that goes with this method will
be returned.
method.getPreconditionMethodSignature(MethodGen)public java.lang.String getPreconditionMethodSignature(org.apache.bcel.generic.MethodGen m)
Examples:
public class MyClass () {
MyClass () { ... }
boolean MyClass_Precondition () { ... }
MyClass (int x) { ... }
boolean MyClass_Precondition (int x) { ... }
void foo (Object o1, Object o2) { ... }
boolean foo_Precondition (Object o1, Object o2) { ... }
}
Signatures are returned in the format used by BCEL.
Examples:
getPreconditionMethodSignature("MyClass()") --> "()Z"
getPreconditionMethodSignature("MyClass(int)") --> "(I)Z"
getPreconditionMethodSignature("foo(Object, Object")) -->
"(Ljava/lang/Object;Ljava/lang/Object;)Z"
m.getPreconditionMethodName(MethodGen)public java.lang.String getPostconditionMethodName(org.apache.bcel.generic.MethodGen m)
Examples:
public class MyClass () {
MyClass () { ... }
boolean MyClass_Postcondition (Void RESULT) { ... }
int foo () { ... }
boolean foo_Postcondition (int RESULT) { ... }
}
method.getPostconditionMethodSignature(MethodGen)public java.lang.String getPostconditionMethodSignature(org.apache.bcel.generic.MethodGen m)
Examples:
public class MyClass () {
MyClass () { ... }
boolean MyClass_Postcondition (Void RESULT) { ... }
MyClass (int x) { ... }
boolean MyClass_Postcondition (int x, Void RESULT) { ... }
int foo (Object o1, Object o2) { ... }
boolean foo_Precondition (Object o1, Object o2, int RESULT) { ... }
}
Signatures are returned in the format used by BCEL.
Examples:
getPostconditionMethodSignature("MyClass()") --> "(Ljava/lang/Void;)Z"
getPostconditionMethodSignature("MyClass(int)") --> "(ILjava/lang/Void;)Z"
getPostconditionMethodSignature("foo(Object, Object")) --gt;
"(Ljava/lang/Object;Ljava/lang/Object;I)Z"
m.getPostconditionMethodName(MethodGen)public java.lang.String getInvariantMethodName(org.apache.bcel.classfile.JavaClass javaclass)
javaclass - the class to get the invariant method name for.
This argument is not actually used, because all
invariant methods have the same name, but should
be included in case things change in the
future.
public java.lang.String getInvariantMethodSignature(org.apache.bcel.classfile.JavaClass javaclass)
javaclass - the class to get the invariant method signature
for. This argument is not actually used,
because all invariant methods have the same
signature, but should be included in case things
change in the future.
public java.lang.String getContractClassName(org.apache.bcel.classfile.JavaClass javaclass)
class MyClass { ... }
class MyClass_CONTRACT { ... }
class Foo extends MyClass { ... }
class Foo_CONTRACT { ... }
javaclass - the class whose contract class name is to be
determined.
javaclass.public java.lang.String getContractClassName(java.lang.String classname)
class MyClass { ... }
class MyClass_CONTRACT { ... }
class Foo extends MyClass { ... }
class Foo_CONTRACT { ... }
classname - the name of the class class whose contract class
name is to be determined.
classname.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||