java.lang
Class Class
java.lang.Object
java.lang.Class
- All Implemented Interfaces:
- Serializable
- public final class Class
- extends Object
- implements Serializable
JML's specification of java.lang.Class
- Version:
- $Revision: 1.20 $
- Author:
- Gary T. Leavens, Erik Poll
Class Specifications |
represents _isInterface <- this.isInterface();
represents _isArray <- this.isArray();
represents _getName <- this.getName(); |
Specifications inherited from class Object |
represents objectState <- org.jmlspecs.lang.JMLDataGroup.IT;
public represents _getClass <- \typeof(this); |
Model Field Summary |
String |
_getName
|
boolean |
_isArray
Needed to specify that invoking isArray() on an object always
produces the same result: no methods include this model field
in their assignable clause, so no methods can alter the
outcome of invoking isArray() on some object. |
boolean |
_isInterface
|
Constructor Summary |
private |
Class()
|
_isInterface
public boolean _isInterface
_isArray
public boolean _isArray
- Needed to specify that invoking isArray() on an object always
produces the same result: no methods include this model field
in their assignable clause, so no methods can alter the
outcome of invoking isArray() on some object. This property
is important when using ESC/Java on specs that use isArray(),
just knowing that isArray() is pure is not enough.
Similar specs could be added to all other pure methods in this Class.
_getName
public String _getName
Class
private Class()
toString
public String toString()
- Overrides:
toString
in class Object
- Specifications: pure non_null
- also
-
public normal_behavior
ensures \result != null&&!\result .equals("")&&(* \result is the name of this class object *);
- Specifications inherited from overridden method in class Object:
non_null -
public normal_behavior
assignable objectState;
ensures \result != null&&\result .equals(this.theString);
ensures (* \result is a string representation of this object *);
- also
-
public code normal_behavior
assignable \nothing;
ensures \result != null&&(* \result is the instance's class name, followed by an @, followed by the instance's hashcode in hex *);
- also
-
public code model_program { ... }
- implies_that
-
assignable objectState;
ensures \result != null;
forName
public static Class forName(non_null String className)
throws ClassNotFoundException
- Throws:
ClassNotFoundException
- Specifications: non_null
-
public normal_behavior
requires className != null&&(* a class named className has been or can be loaded by the defining loader of the current class *);
assignable \not_specified;
ensures \result != null;
- also
-
public behavior
requires className != null;
assignable \not_specified;
ensures true;
signals_only java.lang.LinkageError, java.lang.ExceptionInInitializerError, java.lang.ClassNotFoundException;
signals (java.lang.LinkageError) (* if linkage fails *);
signals (java.lang.ExceptionInInitializerError) (* if the class must be loaded and its initialization throws an exception *);
signals (java.lang.ClassNotFoundException) (* if className can't be located *);
forName
public static Class forName(non_null String name,
boolean initialize,
non_null ClassLoader loader)
throws ClassNotFoundException
- Throws:
ClassNotFoundException
- Specifications: non_null
-
public normal_behavior
requires name != null&&loader != null&&(* a class named name has been/can be loaded by loader *);
assignable \not_specified;
ensures \result != null;
- also
-
public behavior
requires name != null&&loader != null;
assignable \not_specified;
ensures true;
signals_only java.lang.LinkageError, java.lang.ExceptionInInitializerError, java.lang.ClassNotFoundException;
signals (java.lang.LinkageError) (* if linkage fails *);
signals (java.lang.ExceptionInInitializerError) (* if the class must be loaded and its initialization throws an exception *);
signals (java.lang.ClassNotFoundException) (* if name can't be located *);
newInstance
public Object newInstance()
throws InstantiationException,
IllegalAccessException
- Throws:
InstantiationException
IllegalAccessException
- Specifications: pure non_null
isInstance
public boolean isInstance(Object obj)
- Specifications: pure
isAssignableFrom
public boolean isAssignableFrom(Class cls)
- Specifications: pure
isInterface
public boolean isInterface()
- Specifications: pure
-
ensures \result == this._isInterface;
isArray
public boolean isArray()
- Specifications: pure
-
ensures \result == this._isArray;
ensures \elemtype(this) <: \type(java.lang.Object) ==> \result ;
ensures \elemtype(this) == \type(int) ==> \result ;
ensures \elemtype(this) == \type(byte) ==> \result ;
ensures \elemtype(this) == \type(short) ==> \result ;
ensures \elemtype(this) == \type(long) ==> \result ;
ensures \elemtype(this) == \type(char) ==> \result ;
ensures \elemtype(this) == \type(float) ==> \result ;
ensures \elemtype(this) == \type(double) ==> \result ;
ensures \elemtype(this) == \type(boolean) ==> \result ;
isPrimitive
public boolean isPrimitive()
- Specifications: pure
-
ensures \result <==> this == java.lang.Boolean.TYPE||this == java.lang.Character.TYPE||this == java.lang.Byte.TYPE||this == java.lang.Short.TYPE||this == java.lang.Integer.TYPE||this == java.lang.Long.TYPE||this == java.lang.Float.TYPE||this == java.lang.Double.TYPE||this == java.lang.Void.TYPE;
getName
public String getName()
- Specifications: pure non_null
-
ensures \result == this._getName;
getClassLoader
public ClassLoader getClassLoader()
- Specifications: pure
getClassLoader0
ClassLoader getClassLoader0()
- Specifications: pure
getSuperclass
public Class getSuperclass()
- Specifications: pure
getPackage
public Package getPackage()
- Specifications: pure
getInterfaces
public Class[] getInterfaces()
- Specifications: pure non_null
getComponentType
public Class getComponentType()
- Specifications: pure
getModifiers
public int getModifiers()
- Specifications: pure
getSigners
public Object[] getSigners()
- Specifications: pure non_null
setSigners
void setSigners(Object[] signers)
getDeclaringClass
public Class getDeclaringClass()
- Specifications: pure
getClasses
public Class[] getClasses()
- Specifications: pure non_null
getFields
public Field[] getFields()
throws SecurityException
- Throws:
SecurityException
- Specifications: pure non_null
getMethods
public Method[] getMethods()
throws SecurityException
- Throws:
SecurityException
- Specifications: pure non_null
getConstructors
public Constructor[] getConstructors()
throws SecurityException
- Throws:
SecurityException
- Specifications: pure non_null
getField
public Field getField(String name)
throws NoSuchFieldException,
SecurityException
- Throws:
NoSuchFieldException
SecurityException
- Specifications: pure non_null
getMethod
public Method getMethod(String name,
Class[] parameterTypes)
throws NoSuchMethodException,
SecurityException
- Throws:
NoSuchMethodException
SecurityException
- Specifications: pure non_null
getConstructor
public Constructor getConstructor(Class[] parameterTypes)
throws NoSuchMethodException,
SecurityException
- Throws:
NoSuchMethodException
SecurityException
- Specifications: pure non_null
getDeclaredClasses
public Class[] getDeclaredClasses()
throws SecurityException
- Throws:
SecurityException
- Specifications: pure
-
ensures \result != null;
ensures \nonnullelements(\result );
getDeclaredFields
public Field[] getDeclaredFields()
throws SecurityException
- Throws:
SecurityException
- Specifications: pure
-
ensures \result != null;
ensures \nonnullelements(\result );
getDeclaredMethods
public Method[] getDeclaredMethods()
throws SecurityException
- Throws:
SecurityException
- Specifications: pure
-
ensures \result != null;
ensures \nonnullelements(\result );
getDeclaredConstructors
public Constructor[] getDeclaredConstructors()
throws SecurityException
- Throws:
SecurityException
- Specifications: pure non_null
getDeclaredField
public Field getDeclaredField(String name)
throws NoSuchFieldException,
SecurityException
- Throws:
NoSuchFieldException
SecurityException
- Specifications: pure non_null
getDeclaredMethod
public Method getDeclaredMethod(String name,
Class[] parameterTypes)
throws NoSuchMethodException,
SecurityException
- Throws:
NoSuchMethodException
SecurityException
- Specifications: pure non_null
getDeclaredConstructor
public Constructor getDeclaredConstructor(Class[] parameterTypes)
throws NoSuchMethodException,
SecurityException
- Throws:
NoSuchMethodException
SecurityException
- Specifications: pure non_null
getResourceAsStream
public InputStream getResourceAsStream(String name)
- Specifications: pure
getResource
public URL getResource(String name)
- Specifications: pure
getProtectionDomain
public ProtectionDomain getProtectionDomain()
- Specifications: pure
setProtectionDomain0
void setProtectionDomain0(ProtectionDomain pd)
getPrimitiveClass
static Class getPrimitiveClass(String name)
- Specifications: pure
desiredAssertionStatus
public boolean desiredAssertionStatus()
- Specifications: pure
JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.