Package jminusminus
Class Type
java.lang.Object
jminusminus.Type
- Direct Known Subclasses:
- ArrayTypeName,- TypeName
A class for representing j-- types. All types are represented underneath (in the classRep
 field) by Java objects of type Class. These objects represent types in Java, so this should
 ease our interfacing with existing Java classes.
 
Class types (reference types that are represented by the identifiers introduced in class declarations) are represented using TypeName. So for now, every TypeName represents a class. In the future, TypeName could be extended to represent interfaces or enumerations.
IdentifierTypes must be "resolved" at some point, so that all Types having the same name refer to the same Type object. The resolve() method does this.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final TypeThe "any" type (denotes wild expressions).static final TypeThe boolean type.static final TypeThe java.lang.Boolean type.static final TypeThe java.lang.Character type.static final TypeThe java.lang.Double type.static final TypeThe java.lang.Integer type.static final TypeThe java.lang.Long type.static final TypeThe char type.static final TypeA type marker indicating a constructor (having no return type).static final TypeThe double type.static final TypeThe int type.static final TypeThe long type.static final TypeThe null type.static final TypeThe java.lang.Object type.static final TypeThe java.lang.String type.static final TypeThe void type.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionReturns a list of this class' abstract methods.static StringargTypesAsString(Type[] argTypes) Returns a string representation of an array of argument types.static booleanargTypesMatch(Class<?>[] argTypes1, Class<?>[] argTypes2) Returns true if the argument types match, and false otherwise.Returns a string representation for a type being appended to a StringBuffer (for the + and += operations over strings).static booleancheckAccess(int line, Class referencingType, Class type) Returns true if the referenced type is accessible from the referencing type, and false otherwise.booleancheckAccess(int line, Member member) Returns true if the member is accessible from this type, and false otherwise.booleancheckAccess(int line, Type targetType) Returns true if the target type is accessible from this type, and false otherwise.Class<?>classRep()Returns the class representation for this type.Returns an array type's component type.constructorFor(Type[] argTypes) Finds and returns a constructor in this type having the given argument types, or null.booleanReturns true if this type has the same descriptor as other, and false otherwise.Finds and returns a field in this type having the given name, or null.booleanReturns true of this type is declared abstract, and false otherwise.booleanisArray()Returns true if this is an array type, and false otherwise.booleanisFinal()Returns true of this type is declared final, and false otherwise.booleanReturns true if this is an interface type, and false otherwise.booleanisJavaAssignableFrom(Type that) Returns true if this is a supertype of other, and false otherwise.booleanReturns true if this is a primitive type, and false otherwise.booleanReturns true if this is a reference type, and false otherwise.jvmName()Returns the JVM representation of this type's name.booleanmatchesExpected(Type expected) Returns true if this type matches expected, and false otherwise.Finds and returns a method in this type having the given name and argument types, or null.voidmustMatchExpected(int line, Type expectedType) An assertion that this type matches the specified type.voidmustMatchOneOf(int line, Type... expectedTypes) An assertion that this type matches one of the specified types.Returns this type's package name.Resolves this type in the given context and returns the resolved type.voidsetClassRep(Class<?> classRep) Sets the class representation of this type to the specified partial class.static StringsignatureFor(String name, Type[] argTypes) Returns a signature for reporting unfound methods and constructors.Returns the simple (unqualified) name of this type.Returns this type's super type, or null.Returns the JVM descriptor of this type.toString()Returns a string representation of this type.static TypeConstructs and returns a representation for a type from its (Java) class representation, making sure there is a unique representation for each unique type.
- 
Field Details- 
INTThe int type.
- 
CHARThe char type.
- 
BOOLEANThe boolean type.
- 
LONGThe long type.
- 
DOUBLEThe double type.
- 
BOXED_INTThe java.lang.Integer type.
- 
BOXED_CHARThe java.lang.Character type.
- 
BOXED_BOOLEANThe java.lang.Boolean type.
- 
BOXED_LONGThe java.lang.Long type.
- 
BOXED_DOUBLEThe java.lang.Double type.
- 
STRINGThe java.lang.String type.
- 
OBJECTThe java.lang.Object type.
- 
VOIDThe void type.
- 
NULLTYPEThe null type.
- 
ANYThe "any" type (denotes wild expressions).
- 
CONSTRUCTORA type marker indicating a constructor (having no return type).
 
- 
- 
Constructor Details- 
Typeprotected Type()This constructor is to keep the compiler happy.
 
- 
- 
Method Details- 
typeForConstructs and returns a representation for a type from its (Java) class representation, making sure there is a unique representation for each unique type.- Parameters:
- classRep- the Java class representation.
- Returns:
- a type representation of classRep.
 
- 
classRepReturns the class representation for this type.- Returns:
- the class representation for this type.
 
- 
setClassRepSets the class representation of this type to the specified partial class.- Parameters:
- classRep- the partial class.
 
- 
equalsReturns true if this type has the same descriptor as other, and false otherwise.- Parameters:
- other- the other type.
- Returns:
- true if this type has the same descriptor as other, and false otherwise.
 
- 
isArraypublic boolean isArray()Returns true if this is an array type, and false otherwise.- Returns:
- true if this is an array type, and false otherwise.
 
- 
componentTypeReturns an array type's component type.- Returns:
- an array type's component type.
 
- 
superClassReturns this type's super type, or null.- Returns:
- this type's super type, or null.
 
- 
isPrimitivepublic boolean isPrimitive()Returns true if this is a primitive type, and false otherwise.- Returns:
- true if this is a primitive type, and false otherwise.
 
- 
isInterfacepublic boolean isInterface()Returns true if this is an interface type, and false otherwise.- Returns:
- true if this is an interface type, and false otherwise.
 
- 
isReferencepublic boolean isReference()Returns true if this is a reference type, and false otherwise.- Returns:
- true if this is a reference type, and false otherwise.
 
- 
isFinalpublic boolean isFinal()Returns true of this type is declared final, and false otherwise.- Returns:
- true of this type is declared final, and false otherwise.
 
- 
isAbstractpublic boolean isAbstract()Returns true of this type is declared abstract, and false otherwise.- Returns:
- true of this type is declared abstract, and false otherwise.
 
- 
isJavaAssignableFromReturns true if this is a supertype of other, and false otherwise.- Parameters:
- that- the candidate subtype.
- Returns:
- true if this is a supertype of other, and false otherwise.
 
- 
abstractMethodsReturns a list of this class' abstract methods.It has abstract methods if: - Any method declared in the class is abstract or
- its superclass has an abstract method which is not overridden here.
 - Returns:
- a list of this class' abstract methods.
 
- 
mustMatchOneOfAn assertion that this type matches one of the specified types. If there is no match, an error is reported.- Parameters:
- line- the line near which the mismatch occurs.
- expectedTypes- expected types.
 
- 
mustMatchExpectedAn assertion that this type matches the specified type. If there is no match, an error is reported.- Parameters:
- line- the line near which the mismatch occurs.
- expectedType- type with which to match.
 
- 
matchesExpectedReturns true if this type matches expected, and false otherwise.- Parameters:
- expected- the type that this might match.
- Returns:
- true if this type matches expected, and false otherwise.
 
- 
argTypesMatchReturns true if the argument types match, and false otherwise.- Parameters:
- argTypes1- arguments (classReps) of one method.
- argTypes2- arguments (classReps) of another method.
- Returns:
- true if the argument types match, and false otherwise.
 
- 
simpleNameReturns the simple (unqualified) name of this type.- Returns:
- the simple (unqualified) name of this type.
 
- 
toStringReturns a string representation of this type.
- 
toDescriptorReturns the JVM descriptor of this type.- Returns:
- the JVM descriptor of this type.
 
- 
jvmNameReturns the JVM representation of this type's name.- Returns:
- the JVM representation of this type's name.
 
- 
packageNameReturns this type's package name.- Returns:
- this type's package name.
 
- 
argumentTypeForAppendReturns a string representation for a type being appended to a StringBuffer (for the + and += operations over strings).- Returns:
- a string representation for a type being appended to a StringBuffer.
 
- 
methodForFinds and returns a method in this type having the given name and argument types, or null.- Parameters:
- name- the method name.
- argTypes- the argument types.
- Returns:
- a method in this type having the given name and argument types, or null.
 
- 
constructorForFinds and returns a constructor in this type having the given argument types, or null.- Parameters:
- argTypes- the argument types.
- Returns:
- a constructor in this type having the given argument types, or null.
 
- 
fieldForFinds and returns a field in this type having the given name, or null.- Parameters:
- name- the name of the field we want.
- Returns:
- a field in this type having the given name, or null.
 
- 
argTypesAsStringReturns a string representation of an array of argument types.- Parameters:
- argTypes- the array of argument types.
- Returns:
- a string representation of an array of argument types.
 
- 
checkAccessReturns true if the member is accessible from this type, and false otherwise.- Parameters:
- line- the line in which the access occurs.
- member- the member being accessed.
- Returns:
- true if the member is accessible from this type, and false otherwise.
 
- 
checkAccessReturns true if the target type is accessible from this type, and false otherwise.- Parameters:
- line- line in which the access occurs.
- targetType- the type being accessed.
- Returns:
- true if the target type is accessible from this type, and false otherwise.
 
- 
checkAccessReturns true if the referenced type is accessible from the referencing type, and false otherwise.- Parameters:
- line- the line in which the access occurs.
- referencingType- the type attempting the access.
- type- the type that we want to access.
- Returns:
- true if the referenced type is accessible from the referencing type, and false otherwise.
 
- 
resolveResolves this type in the given context and returns the resolved type.- Parameters:
- context- context in which the names are resolved.
- Returns:
- the resolved type.
 
- 
signatureForReturns a signature for reporting unfound methods and constructors.- Parameters:
- name- the message or type name.
- argTypes- the actual argument types.
- Returns:
- a signature for reporting unfound methods and constructors.
 
 
-