Package gw.internal.gosu.parser
Class JavaType
java.lang.Object
gw.lang.reflect.AbstractType
gw.lang.reflect.InnerClassCapableType
gw.internal.gosu.parser.JavaType
- All Implemented Interfaces:
IJavaTypeInternal
,IParameterizableType
,IFileRepositoryBasedType
,IHasInnerClass
,ICanBeAnnotation
,IDefaultArrayType
,IEnhanceableType
,IHasJavaClass
,IType
,IJavaArrayType
,IJavaBackedType
,IJavaBackedTypeData
,IJavaType
,Serializable
- Direct Known Subclasses:
JavaEnumType
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IGosuClassInternal
private IJavaTypeInternal
private boolean
private boolean
private boolean
private boolean
private LockingLazyVar<Boolean>
private boolean
private Boolean
protected IJavaClassInfo
private IJavaTypeInternal
private Class<?>
private LocklessLazyVar<IFunctionType>
private IType[]
private LockingLazyVar<GenericTypeVariable[]>
private ConcurrentMap<String,
IJavaTypeInternal> private String
private String
private String
private IType
private GenericTypeVariable[]
private int
private ITypeInfo
private DefaultTypeLoader
private IType[]
private IJavaTypeInternal
Fields inherited from interface gw.internal.gosu.parser.IJavaTypeInternal
TYPES_BY_CLASS
Fields inherited from interface gw.lang.reflect.IType
EMPTY_ARRAY, EMPTY_TYPE_ARRAY, EMPTY_TYPE_LIST
-
Constructor Summary
ConstructorsModifierConstructorDescriptionJavaType
(IJavaClassInfo cls, DefaultTypeLoader loader) JavaType
(IJavaClassInfo classInfo, DefaultTypeLoader loader, IType[] typeParams) private
JavaType
(IJavaClassInfo arrayClass, IJavaTypeInternal componentType, DefaultTypeLoader loader) private
JavaType
(IJavaClassInfo cls, IType[] typeParams, DefaultTypeLoader loader) (package private)
JavaType
(Class cls, DefaultTypeLoader loader) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addGenericTypes
(IType type, Set<IType> includeGenericTypes) private void
private GenericTypeVariable[]
assignTypeVarsFromTypeParams
(IType[] typeParams) Note a gosu class can be BOTH parameterzied AND generic.byte[]
compile()
(package private) String
static IJavaType[]
convertClassArray
(Class[] args) private ITypeInfo
static IJavaTypeInternal
create
(IJavaClassInfo cls, DefaultTypeLoader loader) Creates the Gosu proxy type for this class.private static IJavaTypeInternal
define
(Class cls, DefaultTypeLoader loader) boolean
static IJavaTypeInternal
get
(Class cls, DefaultTypeLoader loader) Returns the Gosu proxy for this class.Returns a Set of all IIntrinsicTypes that this class is assignable from, including this class.getArrayComponent
(Object array, int iIndex) Returns the value of the indexed component in the specified array object.int
getArrayLength
(Object array) Returns the length of the specified array object.Make an array type from this type.If this is an array type, a type representing the component type of the array.The display name of this intrinsic type.Returns the type immediately enclosing this type.If this is a parameterized type, returns the generic type this type parameterizes.Returns an array of GenericTypeVariables declared with this Generic Type.getInnerClass
(CharSequence name) returns the appropriate inner classprivate IJavaTypeInternal
getInnerClassSimple
(String simpleName) IType[]
private void
getInterfaces
(Class clazz, Set<Class> classes) Returns the java class for this java typeIType[]
int
Returns the modifiers for this type, encoded in an integer.getName()
The fully qualified name of this intrinsic type.The namespace for this class.getParameterizedType
(IType... paramTypes) Assuming this intrinsic type is a Generic type, return the parameterized type associated with the given list of type parameters.static IJavaType
getPrimitiveType
(String strPrimitiveClassName) The relative or unqualified name.IFile[]
Returns the type representing the supertype of this type.protected IType
Get the type information for this intrinsic type.int
Returns the type loader responsible for loading this intrinsic type.IType[]
If this is a parameterized type, returns the specific types used to create this type, null otherwies.boolean
static boolean
hasBeenUpdated
(IJavaTypeInternal type, int tiChecksum, Set<IType> visited) int
hashCode()
private static boolean
haveAncestorsBeenUpdated
(IJavaTypeInternal type, int tiChecksum, Set<IType> visited) private void
init
(IJavaClassInfo cls, DefaultTypeLoader loader) boolean
boolean
boolean
isArray()
True if this is an array.boolean
isAssignableFrom
(IType type) Determines if the type represented by this intrinsic type is either the same as, or is a super-type of the type represented by the specified type parameter.private boolean
boolean
boolean
boolean
boolean
True if this type has been replaced with a newer version of the same name in the type system.boolean
isEnum()
Returns true if this type is an enumeration.boolean
isFinal()
True if this type cannot be extended.boolean
Returns true if this ia a Generic Type.boolean
Returns true if this type is an interface.boolean
Note eventhough some classes are indeed immutable (e.g.boolean
Returns true if this ia a Parameterized Type.boolean
True if this type represents a primitive type e.g., Java int, char, etc.boolean
boolean
isValid()
Defines this type if it is not yet fully defined.private ITypeInfo
makeArrayInstance
(int iLength) Construct an array instance of specified length.private IType
IType requires this method be implemented to ensure IType instances can be centrally defined and cached.void
setAdapterClass
(IGosuClassInternal adapterClass) void
setArrayComponent
(Object array, int iIndex, Object value) Sets the value of the indexed component in the specified array object.void
setComponentType
(IJavaTypeInternal componentType) void
setDiscarded
(boolean bDiscarded) private IJavaTypeInternal
thisRef()
toString()
void
Unload or nullify any references to this IType's ITypeInfo.static void
Methods inherited from class gw.lang.reflect.InnerClassCapableType
resolveRelativeInnerClass
Methods inherited from class gw.lang.reflect.AbstractType
getLiteralMetaType, getMetaType
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface gw.lang.parser.IFileRepositoryBasedType
getJavaName
Methods inherited from interface gw.lang.parser.IHasInnerClass
resolveRelativeInnerClass
Methods inherited from interface gw.lang.reflect.IType
getLiteralMetaType, getMetaType, isDynamic
-
Field Details
-
_strName
-
_typeParams
-
_classInfo
-
_typeInfo
-
_strRelativeName
-
_strSimpleName
-
_allTypesInHierarchy
-
_bArray
private transient boolean _bArray -
_bPrimitive
private transient boolean _bPrimitive -
_bHasSuperType
-
_superType
-
_tempInterfaces
-
_interfaces
-
_functionalInterface
-
_adapterClass
-
_tempGenericTypeVars
-
_lazyGenericTypeVars
-
_bDefiningGenericTypes
private transient boolean _bDefiningGenericTypes -
_parameterizationByParamsName
-
_arrayType
-
_componentType
-
_typeLoader
-
_bDoesNotHaveExplicitTypeInfo
private transient boolean _bDoesNotHaveExplicitTypeInfo -
_explicitTypeInfoClass
-
_bDiscarded
private transient boolean _bDiscarded -
_typeRef
-
_tiChecksum
private transient int _tiChecksum -
_innerClasses
-
_bStrictGenerics
-
SPECIAL_TYPE_INFO
-
-
Constructor Details
-
JavaType
-
JavaType
JavaType(Class cls, DefaultTypeLoader loader) -
JavaType
-
JavaType
private JavaType(IJavaClassInfo arrayClass, IJavaTypeInternal componentType, DefaultTypeLoader loader) -
JavaType
-
-
Method Details
-
get
-
getPrimitiveType
-
define
-
create
-
isDefiningGenericTypes
public boolean isDefiningGenericTypes()- Specified by:
isDefiningGenericTypes
in interfaceIJavaTypeInternal
-
assignGenericTypeVariables
- Specified by:
assignGenericTypeVariables
in interfaceIJavaTypeInternal
-
assignGenericTypeVarPlaceholders
private void assignGenericTypeVarPlaceholders() -
init
-
assignTypeVarsFromTypeParams
Note a gosu class can be BOTH parameterzied AND generic. For example, class Bar{ function blah() : T {...} } class Foo extends Bar {} The class Bar here is parameterized by the type var from Foo, yet it is still a generic class. The blah() method in Foo's typeinfo must have a return type consistent with Foo's type var upper bound, CharSequence. //## todo: maybe we don't need this concept any longer? i.e., parameterization should work correctly regardless. - Parameters:
typeParams
- type parameters- Returns:
- generic type variables
-
getTypeLoader
Description copied from interface:IType
Returns the type loader responsible for loading this intrinsic type.- Specified by:
getTypeLoader
in interfaceIType
-
getName
Description copied from interface:IType
The fully qualified name of this intrinsic type. -
computeQualifiedName
String computeQualifiedName() -
getDisplayName
Description copied from interface:IType
The display name of this intrinsic type. Often this is simply the same asIType.getName()
, but in some cases a type may want to modify it's name for presentation to the user.- Specified by:
getDisplayName
in interfaceIType
-
getRelativeName
Description copied from interface:IType
The relative or unqualified name. For a class this should be just the class name without the package name.- Specified by:
getRelativeName
in interfaceIType
-
getSimpleName
- Specified by:
getSimpleName
in interfaceIJavaTypeInternal
-
getNamespace
Description copied from interface:IType
The namespace for this class. For a java class this will be the package, while for other types of intrinsic types it could be another logical name.- Specified by:
getNamespace
in interfaceIType
-
isArray
public boolean isArray()Description copied from interface:IType
True if this is an array. -
isPrimitive
public boolean isPrimitive()Description copied from interface:IType
True if this type represents a primitive type e.g., Java int, char, etc.- Specified by:
isPrimitive
in interfaceIType
-
makeArrayInstance
Description copied from interface:IType
Construct an array instance of specified length.- Specified by:
makeArrayInstance
in interfaceIType
-
isAssignableFrom
Description copied from interface:IType
Determines if the type represented by this intrinsic type is either the same as, or is a super-type of the type represented by the specified type parameter.- Specified by:
isAssignableFrom
in interfaceIType
-
isAssignableFromJavaBackedType
-
isMutable
public boolean isMutable()Note eventhough some classes are indeed immutable (e.g. java.lang.String) there's no such info in a java class, so we default to mutable. -
getIntrinsicClass
Description copied from interface:IJavaType
Returns the java class for this java type- Specified by:
getIntrinsicClass
in interfaceIJavaType
- Returns:
- the java class for this java type
-
getBackingClassInfo
- Specified by:
getBackingClassInfo
in interfaceIJavaBackedTypeData
- Specified by:
getBackingClassInfo
in interfaceIJavaType
-
getBackingClass
- Specified by:
getBackingClass
in interfaceIHasJavaClass
-
getTypeInfo
Description copied from interface:IType
Get the type information for this intrinsic type.- Specified by:
getTypeInfo
in interfaceIType
- See Also:
-
getAdapterClass
Description copied from interface:IJavaType
Returns the Gosu proxy for this class.- Specified by:
getAdapterClass
in interfaceIJavaType
- Specified by:
getAdapterClass
in interfaceIJavaTypeInternal
-
getAdapterClassDirectly
- Specified by:
getAdapterClassDirectly
in interfaceIJavaTypeInternal
-
loadTypeInfo
-
unloadTypeInfo
public void unloadTypeInfo()Description copied from interface:IType
Unload or nullify any references to this IType's ITypeInfo.- Specified by:
unloadTypeInfo
in interfaceIType
-
isInterface
public boolean isInterface()Description copied from interface:IType
Returns true if this type is an interface.- Specified by:
isInterface
in interfaceIType
-
isEnum
public boolean isEnum()Description copied from interface:IType
Returns true if this type is an enumeration. -
getInterfaces
- Specified by:
getInterfaces
in interfaceIType
- Returns:
- If this is a class, returns a list of all the interfaces this type implements. Similarly, if this is an interface, returns a list of all the interfaces this type extends. In any case, returns an empty list if this type neither implements nor extends interfaces.
-
getSupertype
Description copied from interface:IType
Returns the type representing the supertype of this type. Returns null if this type has no supertype.- Specified by:
getSupertype
in interfaceIType
-
notDeletedSupertype
-
getInnerClasses
- Specified by:
getInnerClasses
in interfaceIHasInnerClass
- Specified by:
getInnerClasses
in interfaceIJavaType
- Returns:
- An array of Java types reflecting all the classes and interfaces declared as members of the class represented by this Class object. These include public, protected, internal, and private classes and interfaces declared by the class, but excludes inherited classes and interfaces.
-
getInnerClass
Description copied from interface:IHasInnerClass
returns the appropriate inner class- Specified by:
getInnerClass
in interfaceIHasInnerClass
- Returns:
-
getInnerClassSimple
-
getSourceFileHandle
- Specified by:
getSourceFileHandle
in interfaceIFileRepositoryBasedType
-
getLoadedInnerClasses
- Specified by:
getLoadedInnerClasses
in interfaceIHasInnerClass
-
getClassType
- Specified by:
getClassType
in interfaceIFileRepositoryBasedType
-
getEnclosingType
Description copied from interface:IType
Returns the type immediately enclosing this type. If this type is not enclosed, returns null.- Specified by:
getEnclosingType
in interfaceIType
-
getGenericType
Description copied from interface:IType
If this is a parameterized type, returns the generic type this type parameterizes. Otherwise, returns null.- Specified by:
getGenericType
in interfaceIJavaType
- Specified by:
getGenericType
in interfaceIType
-
isFinal
public boolean isFinal()Description copied from interface:IType
True if this type cannot be extended. -
isParameterizedType
public boolean isParameterizedType()Description copied from interface:IType
Returns true if this ia a Parameterized Type. Note a Parameterzied Type is not the same as a Generic Type. The difference is that a Parameterized Type is a concrete version of a Generic Type. For instance, the class ArrayListis a Generic Type, while the class ArrayList is a Parameterized Type of the the Generic Type ArrayList . - Specified by:
isParameterizedType
in interfaceIType
-
isGenericType
public boolean isGenericType()Description copied from interface:IType
Returns true if this ia a Generic Type.- Specified by:
isGenericType
in interfaceIType
- See Also:
-
getGenericTypeVariables
Description copied from interface:IType
Returns an array of GenericTypeVariables declared with this Generic Type. Otherwise, returns null if this is not a Generic Type.- Specified by:
getGenericTypeVariables
in interfaceIType
-
getTypeParameters
Description copied from interface:IType
If this is a parameterized type, returns the specific types used to create this type, null otherwies.- Specified by:
getTypeParameters
in interfaceIType
-
getParameterizedType
Description copied from interface:IType
Assuming this intrinsic type is a Generic type, return the parameterized type associated with the given list of type parameters. If the type has not been created yet, creates the parameterized type. Successive calls to this method having identical parameter types must return the identical parameterized type.- Specified by:
getParameterizedType
in interfaceIType
- Parameters:
paramTypes
- The type parameters.- Returns:
- The concrete type associated with the type parameters.
-
getAllTypesInHierarchy
Description copied from interface:IType
Returns a Set of all IIntrinsicTypes that this class is assignable from, including this class. This includes implemented interfaces and superclasses, recursively up the hieararchy. For array types, this will be a Set of all types that its component type is assignable from.- Specified by:
getAllTypesInHierarchy
in interfaceIType
-
addGenericTypes
-
thisRef
-
getArrayType
Description copied from interface:IType
Make an array type from this type. E.g., String -> String[]- Specified by:
getArrayType
in interfaceIType
-
getArrayComponent
public Object getArrayComponent(Object array, int iIndex) throws IllegalArgumentException, ArrayIndexOutOfBoundsException Description copied from interface:IType
Returns the value of the indexed component in the specified array object.- Specified by:
getArrayComponent
in interfaceIType
- Parameters:
array
- An array instance of this intrinsic type.iIndex
- The index of the component to get.- Returns:
- The value of the indexed component in the specified array.
- Throws:
IllegalArgumentException
- If the specified object is not an array.ArrayIndexOutOfBoundsException
- If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
-
setArrayComponent
public void setArrayComponent(Object array, int iIndex, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException Description copied from interface:IType
Sets the value of the indexed component in the specified array object.- Specified by:
setArrayComponent
in interfaceIType
- Parameters:
array
- An array instance of this intrinsic type.iIndex
- The index of the component to set.value
- The new value of the indexed component.- Throws:
IllegalArgumentException
- If the specified object is not an array.ArrayIndexOutOfBoundsException
- If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
-
getInterfaces
-
getArrayLength
Description copied from interface:IType
Returns the length of the specified array object.- Specified by:
getArrayLength
in interfaceIType
- Parameters:
array
- An array instance of this intrinsic type.- Returns:
- The length of the array.
- Throws:
IllegalArgumentException
- If the object argument is not an array.
-
getComponentType
Description copied from interface:IType
If this is an array type, a type representing the component type of the array. Otherwise null.- Specified by:
getComponentType
in interfaceIType
-
setComponentType
- Specified by:
setComponentType
in interfaceIJavaTypeInternal
-
getTypeInfoChecksum
public int getTypeInfoChecksum()- Specified by:
getTypeInfoChecksum
in interfaceIJavaTypeInternal
-
hasAncestorBeenUpdated
public boolean hasAncestorBeenUpdated()- Specified by:
hasAncestorBeenUpdated
in interfaceIJavaTypeInternal
-
haveAncestorsBeenUpdated
private static boolean haveAncestorsBeenUpdated(IJavaTypeInternal type, int tiChecksum, Set<IType> visited) -
hasBeenUpdated
-
writeReplace
- Specified by:
writeReplace
in interfaceIJavaTypeInternal
-
readResolve
Description copied from interface:IType
IType requires this method be implemented to ensure IType instances can be centrally defined and cached.- Specified by:
readResolve
in interfaceIType
- Throws:
ObjectStreamException
-
isValid
public boolean isValid()Description copied from interface:IType
Defines this type if it is not yet fully defined. For instance, if this type has source code associated with it, it must fully compile the source for it to be fully defined. -
getModifiers
public int getModifiers()Description copied from interface:IType
Returns the modifiers for this type, encoded in an integer. The modifiers consist of the constants forpublic
,protected
,private
,final
,static
,abstract
they should be decoded using the methods of classModifier
.- Specified by:
getModifiers
in interfaceIType
- See Also:
-
isAbstract
public boolean isAbstract()- Specified by:
isAbstract
in interfaceIType
-
equals
-
hashCode
public int hashCode() -
toString
-
getExplicitTypeInfo
- Specified by:
getExplicitTypeInfo
in interfaceIJavaTypeInternal
-
convertToTypeInfo
-
setAdapterClass
- Specified by:
setAdapterClass
in interfaceIJavaTypeInternal
-
createAdapterClass
Description copied from interface:IJavaType
Creates the Gosu proxy type for this class.- Specified by:
createAdapterClass
in interfaceIJavaType
- Returns:
- The newly created proxy type.
-
convertClassArray
-
unloadTypes
public static void unloadTypes() -
isDiscarded
public boolean isDiscarded()Description copied from interface:IType
True if this type has been replaced with a newer version of the same name in the type system.- Specified by:
isDiscarded
in interfaceIType
-
setDiscarded
public void setDiscarded(boolean bDiscarded) - Specified by:
setDiscarded
in interfaceIType
-
isCompoundType
public boolean isCompoundType()- Specified by:
isCompoundType
in interfaceIType
-
getCompoundTypeComponents
- Specified by:
getCompoundTypeComponents
in interfaceIType
-
getConcreteClass
- Specified by:
getConcreteClass
in interfaceIDefaultArrayType
-
getTypeFromJavaBackedType
- Specified by:
getTypeFromJavaBackedType
in interfaceIJavaBackedType
-
getRetainedMemory
- Specified by:
getRetainedMemory
in interfaceIJavaType
-
getLoaderParameterizedTypes
- Specified by:
getLoaderParameterizedTypes
in interfaceIParameterizableType
-
isStrictGenerics
public boolean isStrictGenerics()- Specified by:
isStrictGenerics
in interfaceIParameterizableType
-
getSourceFiles
- Specified by:
getSourceFiles
in interfaceIType
-
isAnnotation
public boolean isAnnotation()- Specified by:
isAnnotation
in interfaceICanBeAnnotation
-
getFunctionalInterface
- Specified by:
getFunctionalInterface
in interfaceIType
-
getTheRef
- Overrides:
getTheRef
in classAbstractType
-
isCompilable
public boolean isCompilable()- Specified by:
isCompilable
in interfaceIType
-
compile
public byte[] compile()
-