|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.multijava.util.Utils
org.jmlspecs.jmlrac.TransUtils
org.jmlspecs.jmlrac.AssertionMethod
org.jmlspecs.jmlrac.InvariantLikeMethod
A class for generating assertion check methods for class-level assertions such as invariants and history constraints. There are two types of class-level assertions: instance (non-static) assertions and class (static) assertions. As thus, two types of assertion check methods are generated. An instance assertion check method checks both the instance and class assertions while a class assertion check method checks only the class assertionss. The generated assertion check methods inherit assertions of its superclass interfaces by dynamically invoking the corresponding assertion methods.
The class implements a variant of the Template Pattern
[GoF95], prescribed in the class AssertionMethod.
AssertionMethod| Field Summary |
| Fields inherited from class org.jmlspecs.jmlrac.AssertionMethod |
exceptionToThrow, isStatic, javadoc, methodIdentification, methodName, prefix, typeDecl |
| Fields inherited from class org.jmlspecs.jmlrac.TransUtils |
|
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Fields inherited from interface org.jmlspecs.jmlrac.RacConstants |
MN_CHECK_HC, MN_CHECK_INV, MN_CHECK_POST, MN_CHECK_PRE, MN_CHECK_XPOST, MN_EVAL_OLD, MN_GHOST, MN_INIT, MN_INTERNAL, MN_MODEL, MN_MODEL_PUBLIC, MN_RESTORE_FROM, MN_SAVE_TO, MN_SPEC, MN_SPEC_PUBLIC, TN_JMLCHECKABLE, TN_JMLSURROGATE, TN_JMLUNIT_TEST_POSTFIX, TN_JMLUNIT_TESTDATA_POSTFIX, TN_JMLVALUE, TN_SURROGATE, VN_ASSERTION, VN_CATCH_VAR, VN_CLASS_INIT, VN_CONSTRUCTED, VN_DELEGEE, VN_ERROR_SET, VN_EXCEPTION, VN_FREE_VAR, VN_INIT, VN_OLD_VAR, VN_POST_VAR, VN_PRE_VAR, VN_PRECOND, VN_RAC_COMPILED, VN_RAC_LEVEL, VN_RESULT, VN_STACK_VAR, VN_XRESULT |
| Constructor Summary | |
InvariantLikeMethod(boolean isStatic,
JmlTypeDeclaration typeDecl)
Construct a new InvariantLikeMethod object. |
|
| Method Summary | |
protected StringBuffer |
buildHeader(String returnType,
String name,
JFormalParameter[] parameters,
CClassType[] exceptions)
Builds and returns the method header of the assertion check method as a string. |
protected boolean |
canInherit()
Indicates whether the generated assertion method should try to dynamically inherit the corresponding assertion method of the superclass or interfaces. |
protected String |
formalParameters()
Returns the formal parameters of the assertion check method. |
JMethodDeclarationType |
generate(RacNode stmt)
Generate and return a type-level assertion check method such as invariants and history constraints. |
protected String |
inheritAssertion(JFormalParameter[] parameters)
Return the code to inherit assertions of the superclass and interfaces, i.e., to call the assertion check method of the superclass and interfaces and appropriately accumulate the result to the assertion variable (e.g., conjunction). |
protected String |
inheritCallArgs()
Returns, in the string form, the arguments for calling supertype's constraint check method. |
protected String |
inheritCallArgTypes()
Returns, in the string form, the parameter types of the supertype's assertion check method. |
protected String |
inheritFrom(CClass clazz)
Return the code that, if executed, inherits invariant-like assertions such as invariants and constraints from the given class, clazz. |
protected String |
nonReflectiveCall(CClass clazz)
Return code that calls non-reflectively the assertion check method of the given supertype, claszz. |
protected String |
reflectiveCall(CClass clazz)
Return code that calls reflectively the assertion check method of the given supertype, claszz. |
| Methods inherited from class org.jmlspecs.jmlrac.AssertionMethod |
checker, hasExplicitSuperClass |
| Methods inherited from class org.multijava.util.Utils |
assertTrue, assertTrue, combineArrays, escapeString, escapeString, fail, fail, getFilePath, hasFlag, hasOtherFlags, parsePathParts, relativePathTo, splitQualifiedName, splitQualifiedName, stripJavaModifiers, stripNonJavaModifiers, stripPrivateModifier, unescapeString, vectorToArray, vectorToIntArray |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public InvariantLikeMethod(boolean isStatic,
JmlTypeDeclaration typeDecl)
InvariantLikeMethod object.
isStatic - the kind of assertion check method to generate;
true for static and false for
non-static (instance) assertion check method.typeDecl - the target type declaration whose assertion check
methods are to be generated.| Method Detail |
public JMethodDeclarationType generate(RacNode stmt)
stmt): (1) code to check the inherited assertions
if any, and (2) code to throw an appropriate exception to
notify an assertion violation.
stmt - code to evaluate the assertions; the result is supposed
to be stored in the variable VN_ASSERTION.
A null value means that no assertion is
specified or the assertion is not executable.
protected StringBuffer buildHeader(String returnType,
String name,
JFormalParameter[] parameters,
CClassType[] exceptions)
buildHeader in class AssertionMethodreturnType - return typename - method nameparameters - formal parametersexceptions - checked exceptionsprotected String formalParameters()
protected String inheritAssertion(JFormalParameter[] parameters)
parameters - parameters to the inherited assertion check method;
not used in this specialization.protected String inheritFrom(CClass clazz)
clazz. Because dynamic delegation is
expensive, the inherting code is short-circuited in that it is
executed only if the asssertion is not violated yet; i.e., not
executed if the assertion is already violated in the inheriting
class or in other classes whose assertions already inherited.
reflectiveCall(CClass),
nonReflectiveCall(CClass)protected String reflectiveCall(CClass clazz)
claszz.
inheritFrom(CClass)protected String nonReflectiveCall(CClass clazz)
claszz.
inheritFrom(CClass)protected String inheritCallArgTypes()
reflectiveCall(CClass)protected String inheritCallArgs()
reflectiveCall(CClass)protected boolean canInherit()
also protected normal_behavior ensures \result == (!isStatic && (hasExplicitSuperClass() || typeDecl.interfaces().length > 0));
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||