|
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
org.jmlspecs.jmlrac.ConstraintMethod
org.jmlspecs.jmlrac.MotherConstraintMethod
A class for generating constraint check methods that check locally
specified type constraints and inherit constraints from
supertypes. The generated constraint methods are supposed to be
called by wrapper methods and constructors. This class can generate
both instance and static constraint check methods. For details on
constraint check methods, refer to the class
ConstraintMethod.
The class implements a variant of the Template Pattern
[GoF95], prescribed in the class AssertionMethod.
AssertionMethod| Field Summary | |
private List |
restoreMethods
The names of the restoration methods that can restore the correct values for old expressions appearing in the constraint clause in the presence of recursive method calls. |
| 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 | |
protected |
MotherConstraintMethod(boolean isStatic,
JmlTypeDeclaration typeDecl,
String postfix,
List restoreMethods)
Construct a new instance. |
|
MotherConstraintMethod(boolean isStatic,
JmlTypeDeclaration typeDecl,
List restoreMethods)
Construct a new instance. |
| Method Summary | |
protected StringBuffer |
buildHeader(String returnType,
String name,
JFormalParameter[] parameters,
CClassType[] exceptions)
Builds, in a string form, the header of constraint method. |
protected String |
checker(boolean initValue,
RacNode stmt,
JFormalParameter[] params)
Returns the given constraint check code, stmt,
wrapped with code to inherit supertypes's constraints. |
JMethodDeclarationType |
generate(RacNode stmt)
Returns a constraint check method with the given body, stmt. |
protected String |
inheritAssertion(JFormalParameter[] parameters)
Return the code to inherit constraints of the superclass and interfaces, i.e., to call the constraint methods of the superclass and interfaces. |
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 formal parameter types of the supertype's constraint check method. |
protected String |
inheritFrom(boolean isWeaksubtype,
CClass clazz)
Returns code that, if executed, inherits constraints from the given type, clazz. |
protected String |
nonReflectiveCall(boolean isWeakly,
CClass clazz)
Return code, in the string form, that calls non-reflectively the constraint check method of the given supertype, claszz. |
private static String |
postfix(boolean isStatic,
JmlTypeDeclaration typeDecl)
Returns the postfix to be used for constraint check method's name. |
protected String |
reflectiveCall(boolean isWeakly,
CClass clazz)
Return code, in the string form, that calls reflectively the constraint check method of the given supertype, claszz. |
| Methods inherited from class org.jmlspecs.jmlrac.ConstraintMethod |
formalParameters |
| Methods inherited from class org.jmlspecs.jmlrac.InvariantLikeMethod |
canInherit, inheritFrom, nonReflectiveCall, reflectiveCall |
| Methods inherited from class org.jmlspecs.jmlrac.AssertionMethod |
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 |
| Field Detail |
private List restoreMethods
private invariant (\forall Object o; restoreMethods.contains(o); o instanceof String);
| Constructor Detail |
public MotherConstraintMethod(boolean isStatic,
JmlTypeDeclaration typeDecl,
List restoreMethods)
requires (\forall Object o; restoreMethods.contains(o); o instanceof String);
isStatic - the kind of constraint method to generate;
true for static and false
for non-static (instance) constraint method.typeDecl - the target type declaration whose constraint methods
are to be generated.restoreMethods - the names of resore methods to be used to restore
the values of old expression fields.
protected MotherConstraintMethod(boolean isStatic,
JmlTypeDeclaration typeDecl,
String postfix,
List restoreMethods)
requires typeDecl != null; requires (\forall Object o; restoreMethods.contains(o); o instanceof String);
isStatic - the kind of constraint method to generate;
true for static and false
for non-static (instance) constraint method.typeDecl - the target type declaration whose constraint methods
are to be generated.restoreMethods - the names of resore methods to be used to restore
the values of old expression fields.| Method Detail |
private static String postfix(boolean isStatic,
JmlTypeDeclaration typeDecl)
[static|instance$T].
public JMethodDeclarationType generate(RacNode stmt)
stmt. Appended to the body (stmt) are
(1) code to check the inherited assertions if any, and (2)
code to throw an appropriate exception to notify an assertion
violation.
generate in class InvariantLikeMethodstmt - 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)
public [static] void name(String rac$msg, String rac$name,
String rac$params)
buildHeader in class InvariantLikeMethodreturnType - return typename - method nameparameters - formal parametersexceptions - checked exceptions
protected String checker(boolean initValue,
RacNode stmt,
JFormalParameter[] params)
stmt,
wrapped with code to inherit supertypes's constraints. For each
supertype, its strong or weak form of constraint check method is
called to inherit its constraints.
checker in class AssertionMethodinitValue - not usedstmt - constraint check code to be wrappedparams - not usedprotected String inheritAssertion(JFormalParameter[] parameters)
inheritAssertion in class InvariantLikeMethodparameters - parameters to the inherited assertion check method;
not used in this specialization.
protected String inheritFrom(boolean isWeaksubtype,
CClass clazz)
clazz.
#reflectiveCall(CClass),
#nonReflectiveCall(CClass)
protected String reflectiveCall(boolean isWeakly,
CClass clazz)
claszz. If the argument, isWeakly is
true, the code calls the supertype's constraint method that
checks constraints according to the weak subtyping; otherwise,
called is the one that checks constraints according to the
strong form of subtyping.
inheritFrom(boolean, CClass)
protected String nonReflectiveCall(boolean isWeakly,
CClass clazz)
claszz. If the argument, isWeakly is
true, the code calls the supertype's constraint method that
checks constraints according to the weak subtyping; otherwise,
called is the one that checks constraints according to the
strong form of subtyping.
inheritFrom(boolean, CClass)protected String inheritCallArgTypes()
inheritCallArgTypes in class ConstraintMethodreflectiveCall(boolean, CClass),
nonReflectiveCall(boolean, CClass)protected String inheritCallArgs()
inheritCallArgs in class ConstraintMethodreflectiveCall(boolean, CClass),
nonReflectiveCall(boolean, CClass)
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||