Class VoidType
- java.lang.Object
-
- randoop.types.Type
-
- randoop.types.VoidType
-
- All Implemented Interfaces:
Comparable<Type>
public class VoidType extends Type
Representsvoid
. Technically,void
is used to indicate that a method has no return values, and is not a type. However, we need to pretend that it is to be able to represent typed operations.The decision to have
void
be a separate "type" is counter to the fact that the reflection methodClass.isPrimitive()
returns true forvoid
.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
VoidType()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
getBinaryName()
Returns the binary name of this type, including type arguments if this is a parameterized type (so, it isn't really a binary name).String
getFqName()
Returns the fully-qualified name of this type, including type arguments if this is a parameterized type.Class<?>
getRuntimeClass()
Returns the runtimeClass
object for this type.String
getSimpleName()
Returns the name of this type without type arguments or package qualifiers.static VoidType
getVoidType()
int
hashCode()
boolean
isAssignableFrom(Type sourceType)
Indicates whether there is an assignment conversion from a sourceType
to this type.boolean
isSubtypeOf(Type otherType)
Test whether this type is a subtype of the given type according to transitive closure of definition of the direct supertype relation in section 4.10 of JLS for Java SE 8.boolean
isVoid()
Indicate whether this type is void.-
Methods inherited from class randoop.types.Type
applyCaptureConversion, compareTo, forClass, forFullyQualifiedName, forName, forType, forValue, getCanonicalName, getRawtype, getTypeforFullyQualifiedName, getUnqualifiedBinaryName, hasCaptureVariable, hasWildcard, isArray, isAssignableFromTypeOf, isBoxedPrimitive, isClass, isClassOrInterfaceType, isEnum, isGeneric, isGeneric, isInterface, isNonreceiverType, isObject, isParameterized, isPrimitive, isRawtype, isReferenceType, isString, isVariable, runtimeClassIs, substitute, toString
-
-
-
-
Field Detail
-
value
private static final VoidType value
-
-
Method Detail
-
getVoidType
public static VoidType getVoidType()
-
getRuntimeClass
public Class<?> getRuntimeClass()
Description copied from class:Type
Returns the runtimeClass
object for this type. For use when reflection is needed.Note that type variables and the null reference type do not have a runtime class, and this method will return null in those cases.
This method should not be confused with the inherited
Object.getClass()
method, which returns theClass<?>
for theType
object, and not of the represented type. For instance, if aType
objectt
represented the Java typeint
, thent.getRuntimeClass()
would returnint.class
whilet.getClass()
would returnType.class
.- Specified by:
getRuntimeClass
in classType
- Returns:
- the
Class
that is the runtime representation of the type, or null if this type is a type variable or null reference type
-
getFqName
public String getFqName()
Description copied from class:Type
Returns the fully-qualified name of this type, including type arguments if this is a parameterized type. Forjava.util.List<T>
return"java.util.List<T>"
.
-
getBinaryName
public String getBinaryName()
Description copied from class:Type
Returns the binary name of this type, including type arguments if this is a parameterized type (so, it isn't really a binary name). Forjava.util.List<T>
return"java.util.List<T>"
.- Specified by:
getBinaryName
in classType
- Returns:
- the binary name for this type
-
getSimpleName
public String getSimpleName()
Description copied from class:Type
Returns the name of this type without type arguments or package qualifiers. Forjava.util.List<T>
, returns"List"
.- Specified by:
getSimpleName
in classType
- Returns:
- the name of this type without type arguments
-
isVoid
public boolean isVoid()
Description copied from class:Type
Indicate whether this type is void.
-
isSubtypeOf
public boolean isSubtypeOf(Type otherType)
Test whether this type is a subtype of the given type according to transitive closure of definition of the direct supertype relation in section 4.10 of JLS for Java SE 8.Returns false, since
void
is not a subtype of any type- Overrides:
isSubtypeOf
in classType
- Parameters:
otherType
- the possible supertype- Returns:
- true if this type is a subtype of the given type, false otherwise
-
isAssignableFrom
public boolean isAssignableFrom(Type sourceType)
Indicates whether there is an assignment conversion from a sourceType
to this type. (In other words, a value of the source type can be assigned to an l-value of this type.) Returns true if this is a legal assignment conversion:Variablethis = Expressionsourcetype.
Based on the definition of assignment context in section 5.2 of the Java Language Specification, a value of one type is assignable to a variable of another type if the first type can be converted to the second by
- an identity conversion (section 5.1.1),
- a widening primitive conversion (section 5.1.2),
- a widening reference conversion (section 5.1.5),
- a boxing conversion (5.1.7), or
- an unboxing conversion (section 5.1.8) possibly followed by a widening conversion.
Return false because cannot assign to void.
- Overrides:
isAssignableFrom
in classType
- Parameters:
sourceType
- the type to test for assignability- Returns:
- true if this type can be assigned from the source type, and false otherwise
-
-