|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jmlspecs.jmlrac.runtime.JMLChecker
A class to set various runtime options and to check and report runtime assertion violations.
| Nested Class Summary | |
static class |
JMLChecker.CoverageCount
|
| Field Summary | |
static JMLNonExecutableException |
ANGELIC_EXCEPTION
An exception object indicating angelic undefinedness. |
static HashMap |
classes
A map from fully quallified class names to class objects. |
static int |
CONSTRAINT
|
protected static Map |
coverage
A map to hold information about coverage |
static RuntimeException |
DEMONIC_EXCEPTION
An exception object indicating demonic undefinedness. |
static int |
INTRACONDITION
|
static int |
INVARIANT
|
protected static int |
level
Runtime option indicating the assertion check level, the kinds of assertions to be checked. |
static Object |
NO_CLASS
A unique object to indicate non-existing class. |
static int |
POSTCONDITION
|
static int |
PRECONDITION
|
static int |
PROTOCOL
|
private static boolean |
reportAssumptionViolation
Indicates whether an assumption violation should be reported to the user by throwing an appropriate exception |
protected static Set |
threadsBeingChecked
Stores a flag per thread to turn assertion check on/off for every thread to avoid recursive assertion checking. |
| Fields inherited from interface org.jmlspecs.jmlrac.runtime.JMLOption |
ALL, NONE, PRECONDITIONS_ONLY |
| Constructor Summary | |
JMLChecker()
|
|
| Method Summary | |
static void |
addCoverage(String location,
boolean value)
|
static void |
clearCoverage()
|
static void |
enter()
Indicates the start of assertion check by the current thread. |
static void |
exit()
Indicates the end of assertion check for the current thread. |
static int |
getLevel()
Returns the current global runtime assertion check level. |
static int |
getLevel(Class clazz)
Returns the current runtime assertion check level of the given class, clazz. |
private static Class |
getRacClass(Class clazz)
Returns the runtime assertion checker class of the given class, clazz. |
static Object |
getSurrogate(String name,
Class clazz,
Object thisObj)
Returns a surrogate object, an instance of the given surrogate class clazz, that is suitable for statically
calling JML access methods on the object thisObj. |
static boolean |
inheritedFrom(Class clazz,
String name,
Class[] params)
Returns true if a method named name with the
formal parameter types, params, can be inherited
from the type, class, or its supertypes. |
static boolean |
isActive(int type)
Determines if the runtime code for checking this type of assertion should be executed. |
static boolean |
isRACCompiled(Class clazz)
Returns true only if the given class, clazz, is
compiled with runtime assertion check code. |
static boolean |
reportAssumptionViolation()
Indicates whether an assumption violation should be reported to the user by throwing an appropriate exception (i.e., JMLIntraconditionError). |
static void |
reportAssumptionViolation(boolean flag)
Sets whether an assumption violation should be reported to the user by throwing an appropriate exception (i.e., JMLIntraconditionError). |
static void |
reportCoverage(PrintStream writer)
|
static void |
setLevel(int l)
Sets the global runtime assertion check level to the level l. |
static void |
setLevel(Class clazz,
int l)
Sets the runtime assertion check level of the class, clazz, to the level, l. |
static String |
toString(boolean i)
Returns the string representation of the given argument. |
static String |
toString(byte i)
Returns the string representation of the given argument. |
static String |
toString(char i)
Returns the string representation of the given argument. |
static String |
toString(double value)
Returns the string representation of the given argument. |
static String |
toString(float value)
Returns the string representation of the given argument. |
static String |
toString(int i)
Returns the string representation of the given argument. |
static String |
toString(Object obj)
Returns the result of invoking the toString method
to the argument, obj. |
static String |
toString(long i)
Returns the string representation of the given argument. |
static String |
toString(short i)
Returns the string representation of the given argument. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static int level
JMLOption.ALL.
public invariant level == JMLOption.NONE || level == JMLOption.PRECONDITIONS_ONLY || level == JMLOption.ALL;
protected static Set threadsBeingChecked
private static boolean reportAssumptionViolation
public static HashMap classes
NO_CLASS, it
means that there is no such named class. This map is used by
the generated method rac$forName(String), to save
class lookup and load time.
public static final Object NO_CLASS
classes.
public static final JMLNonExecutableException ANGELIC_EXCEPTION
public static final RuntimeException DEMONIC_EXCEPTION
public static final int PRECONDITION
public static final int POSTCONDITION
public static final int INVARIANT
public static final int CONSTRAINT
public static final int INTRACONDITION
public static final int PROTOCOL
protected static Map coverage
| Constructor Detail |
public JMLChecker()
| Method Detail |
public static boolean isRACCompiled(Class clazz)
clazz, is
compiled with runtime assertion check code.
public static void setLevel(int l)
l.
normal_behavior requires l == NONE || l == PRECONDITIONS_ONLY || l == ALL; assignable level; ensures level == l;
public static int getLevel()
NONE,
PRECONDITIONS_ONLY, or ALL.
normal_behavior assignable \nothing; ensures \result == level;
public static void setLevel(Class clazz,
int l)
clazz, to the level, l. If no such
class exists, this method has no effect.
normal_behavior requires l == NONE || l == PRECONDITIONS_ONLY || l == ALL; assignable \not_specified;
private static Class getRacClass(Class clazz)
clazz. If the given class is an interface, its
surrogate class is returned; otherwise, the given class itself
is returned.
public static boolean inheritedFrom(Class clazz,
String name,
Class[] params)
name with the
formal parameter types, params, can be inherited
from the type, class, or its supertypes. If
either clazz or name is null, false
is returned.
public static int getLevel(Class clazz)
clazz. The returned value is
NONE, PRECONDITIONS_ONLY, or
ALL. If no such class is found or the class is not
compiled with runtime assertion check code, NONE
is returned.
public static boolean reportAssumptionViolation()
JMLIntraconditionError).
The default is to report assumption violations.
reportAssumptionViolation(boolean)public static void reportAssumptionViolation(boolean flag)
JMLIntraconditionError).
The default is to report assumption violations.
reportAssumptionViolation()public static void enter()
normal_behavior old Thread cur = Thread.currentThread(); requires !threadsBeingChecked.contains(cur); assignable threadsBeingChecked; ensures (* threadsBeingChecked.add(cur) *);
public static void exit()
normal_behavior old Thread cur = Thread.currentThread(); requires threadsBeingChecked.contains(cur); assignable threadsBeingChecked; ensures (* threadsBeingChecked.remove(cur) *);
public static boolean isActive(int type)
type - Type of the current assertion check (e.g., PRECONDITION)
public static Object getSurrogate(String name,
Class clazz,
Object thisObj)
clazz, that is suitable for statically
calling JML access methods on the object thisObj.
The argument clazz must be a surrogate class. If
the object thisObj itself is a surrogate, the
delegee's surrogate cache is looked upon for an existing
surrogate object or creating a new one; otherwise, the object's
surrogate cache is looked upon. The arument name
equals to clazz.getName(); it is passed in for the performance
reason, i.e., to prevent extra calls to the method getName().
public static String toString(Object obj)
toString method
to the argument, obj. If the argument is null, "null"
is returned. If the invocation encounters an exception,
"UNKNOWN" is returned; otherwise, the result of invocation
is returned.
public static String toString(boolean i)
public static String toString(byte i)
public static String toString(char i)
public static String toString(int i)
public static String toString(short i)
public static String toString(long i)
public static String toString(float value)
public static String toString(double value)
public static void clearCoverage()
public static void addCoverage(String location,
boolean value)
public static void reportCoverage(PrintStream writer)
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||