|
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
An abstract class for generating assertion check methods
for specific kinds of assertions such as preconditions, normal and
exceptional postconditions, invariants and (history) constraints.
The generated assertion check methods inherit the superclass's
assertions by dynamically invoking the superclass's corresponding
assertion check methods. For example, the precondition check method
of a method, m, invokes dynamically the
m's precondition method of the superclass if the
method m is overriden in the subclass. In general,
the following rules are applied for inheriting assertions.
weakly annotation in the extends clause.
Not implemented yet!
The class is implemented with a variant of the Template Pattern
[GoF95].
The abstract method generate is supposed to call the
methods buildHeader and checker,
respectively, to compose the header and the body of the assertion method.
The method checker calls the query method
canInherit to decide whether to generate code for inheriting
specifications or not. The actual code for inheritance is generated
by calling the method inheritAssertion.
generate {abstract}
buildHeader
checker
canInherit {abstract}
inheritAssertion
| Field Summary | |
protected String |
exceptionToThrow
name of exception class to be thrown if assertions are violated. |
protected boolean |
isStatic
static-ness of assertion method |
protected String |
javadoc
Javadoc comment to be added to the generated method. |
protected String |
methodIdentification
name of the target method for printing assertion violation error. |
protected String |
methodName
name of assertion method |
protected String |
prefix
Name prefix of the method to be inherited, e.g., MN_CHECK_PRE |
protected JmlTypeDeclaration |
typeDecl
target type declaration for generating assertion methods |
| 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 | |
AssertionMethod()
|
|
| Method Summary | |
protected StringBuffer |
buildHeader(String returnType,
String name,
JFormalParameter[] parameters,
CClassType[] exceptions)
Builds and returns a method header as a string. |
protected abstract boolean |
canInherit()
Indicates whether the generated assertion method should try to dynamically inherit the corresponding assertion method of the superclass. |
protected String |
checker(boolean initValue,
RacNode stmt,
JFormalParameter[] params)
Returnd the assertion check code ( stmt) wrapped with
code to inherit superclass's assertions if any, and to signal
an assertion violation if it happens at runtime. |
abstract JMethodDeclarationType |
generate(RacNode stmt)
Generates and returns an assertion checking method. |
protected boolean |
hasExplicitSuperClass()
Returns true if the type being translated has an explicitly specified superclass. |
protected abstract String |
inheritAssertion(JFormalParameter[] parameters)
Returnd the code to inherit the superclass's assertions, i.e., to call the superclass's assertion check method and appropriately accumulate the result to the assertion variable (e.g., conjunction). |
| 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 |
| Field Detail |
protected JmlTypeDeclaration typeDecl
protected String prefix
protected boolean isStatic
protected String methodName
protected String exceptionToThrow
protected String javadoc
protected String methodIdentification
| Constructor Detail |
public AssertionMethod()
| Method Detail |
public abstract JMethodDeclarationType generate(RacNode stmt)
stmt) code to check the inherited
assertions if any, and code to throw an appropriate exception
to notify an assertion violation if it happens at runtime.
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 String checker(boolean initValue,
RacNode stmt,
JFormalParameter[] params)
stmt) wrapped with
code to inherit superclass's assertions if any, and to signal
an assertion violation if it happens at runtime. The assertion
check code (stmt), if non-null,
evaluates all assertions specified in the class, conjoin the results,
and store the final result to the variable VN_ASSERTION,
called the assertion variable. The assertion variable
is supposed to be declared in the block that encloses the assertion
check code.
initValue - initial value of the assertion variable.stmt - assertion check code to wrapparams - parameters to call the inherited check method if necessary.protected abstract String inheritAssertion(JFormalParameter[] parameters)
parameters - parameters of the superclass's assertion check method
protected StringBuffer buildHeader(String returnType,
String name,
JFormalParameter[] parameters,
CClassType[] exceptions)
returnType - return typename - method nameparameters - formal parametersexceptions - checked exceptionsprotected abstract boolean canInherit()
protected boolean hasExplicitSuperClass()
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||