APIdia Launch Partner
Top Description Methods
sun.reflect.generics.factory

public Interface GenericsFactory

Known Direct Implementers
sun.reflect.generics.factory.CoreReflectionFactory
Imports
java.lang.reflect.ParameterizedType, .Type, .TypeVariable, .WildcardType, sun.reflect.generics.tree.FieldTypeSignature

A factory interface for reflective objects representing generic types. Implementors (such as core reflection or JDI, or possibly javadoc will manufacture instances of (potentially) different classes in response to invocations of the methods described here.

The intent is that reflective systems use these factories to produce generic type information on demand. Certain components of such reflective systems can be independent of a specific implementation by using this interface. For example, repositories of generic type information are initialized with a factory conforming to this interface, and use it to generate the type information they are required to provide. As a result, such repository code can be shared across different reflective systems.

Method Summary

Modifier and TypeMethod and Description
public TypeVariable<?>

Returns:

- the type variable with name name, or null
findTypeVariable
(String
- the name of the type variable to search for
name
)

Returns the type variable with name name, if such a type variable is declared in the scope used to create this factory.

public Type

Returns:

a (possibly generic) array type.
makeArrayType
(Type
- the component type of the array
componentType
)

Returns a (possibly generic) array type.

public Type

Returns:

the reflective representation of type boolean.
makeBool
()

Returns the reflective representation of type boolean.

public Type

Returns:

the reflective representation of type byte.
makeByte
()

Returns the reflective representation of type byte.

public Type

Returns:

the reflective representation of type char.
makeChar
()

Returns the reflective representation of type char.

public Type

Returns:

the reflective representation of type double.
makeDouble
()

Returns the reflective representation of type double.

public Type

Returns:

the reflective representation of type float.
makeFloat
()

Returns the reflective representation of type float.

public Type

Returns:

the reflective representation of type int.
makeInt
()

Returns the reflective representation of type int.

public Type

Returns:

the reflective representation of type long.
makeLong
()

Returns the reflective representation of type long.

public Type
public ParameterizedType

Returns:

- a parameterized type representing the instantiation of the declaration with the actual type arguments
makeParameterizedType
(Type
- the generic type declaration that is to be instantiated
declaration
,
Type[]
- the list of actual type arguments
typeArgs
,
Type owner)

Returns an instance of the ParameterizedType interface that corresponds to a generic type instantiation of the generic declaration declaration with actual type arguments typeArgs.

public Type

Returns:

the reflective representation of type short.
makeShort
()

Returns the reflective representation of type short.

public TypeVariable<?>

Returns:

a new type variable declaration
makeTypeVariable
(String
The name of the type variable
name
,
FieldTypeSignature[]
An array of abstract syntax trees representing the upper bound(s) on the type variable being declared
bounds
)

Returns a new type variable declaration.

public Type

Returns:

the reflective representation of void.
makeVoid
()

Returns the reflective representation of void.

public WildcardType

Returns:

a new wildcard type variable
makeWildcard
(FieldTypeSignature[]
An array of abstract syntax trees representing the upper bound(s) on the type variable being declared
ubs
,
FieldTypeSignature[]
An array of abstract syntax trees representing the lower bound(s) on the type variable being declared
lbs
)

Returns a new wildcard type variable.

Method Detail

findTypeVariableback to summary
public TypeVariable<?> findTypeVariable(String name)

Returns the type variable with name name, if such a type variable is declared in the scope used to create this factory. Returns null otherwise.

Parameters
name:String

- the name of the type variable to search for

Returns:TypeVariable<?>

- the type variable with name name, or null

Exceptions
NullPointerException:
if any of actual parameters are null
makeArrayTypeback to summary
public Type makeArrayType(Type componentType)

Returns a (possibly generic) array type. If the component type is a parameterized type, it must only have unbounded wildcard arguments, otherwise a MalformedParameterizedTypeException is thrown.

Parameters
componentType:Type

- the component type of the array

Returns:Type

a (possibly generic) array type.

Exceptions
MalformedParameterizedTypeException:
if componentType is a parameterized type with non-wildcard type arguments
NullPointerException:
if any of the actual parameters are null
makeBoolback to summary
public Type makeBool()

Returns the reflective representation of type boolean.

Returns:Type

the reflective representation of type boolean.

makeByteback to summary
public Type makeByte()

Returns the reflective representation of type byte.

Returns:Type

the reflective representation of type byte.

makeCharback to summary
public Type makeChar()

Returns the reflective representation of type char.

Returns:Type

the reflective representation of type char.

makeDoubleback to summary
public Type makeDouble()

Returns the reflective representation of type double.

Returns:Type

the reflective representation of type double.

makeFloatback to summary
public Type makeFloat()

Returns the reflective representation of type float.

Returns:Type

the reflective representation of type float.

makeIntback to summary
public Type makeInt()

Returns the reflective representation of type int.

Returns:Type

the reflective representation of type int.

makeLongback to summary
public Type makeLong()

Returns the reflective representation of type long.

Returns:Type

the reflective representation of type long.

makeNamedTypeback to summary
public Type makeNamedType(String name)
makeParameterizedTypeback to summary
public ParameterizedType makeParameterizedType(Type declaration, Type[] typeArgs, Type owner)

Returns an instance of the ParameterizedType interface that corresponds to a generic type instantiation of the generic declaration declaration with actual type arguments typeArgs. If owner is null, the declaring class of declaration is used as the owner of this parameterized type.

This method throws a MalformedParameterizedTypeException under the following circumstances: If the type declaration does not represent a generic declaration (i.e., it is not an instance of GenericDeclaration). If the number of actual type arguments (i.e., the size of the array typeArgs) does not correspond to the number of formal type arguments. If any of the actual type arguments is not an instance of the bounds on the corresponding formal.

Parameters
declaration:Type

- the generic type declaration that is to be instantiated

typeArgs:Type[]

- the list of actual type arguments

Returns:ParameterizedType

- a parameterized type representing the instantiation of the declaration with the actual type arguments

Exceptions
MalformedParameterizedTypeException:
if the instantiation is invalid
NullPointerException:
if any of declaration, typeArgs or any of the elements of typeArgs are null
makeShortback to summary
public Type makeShort()

Returns the reflective representation of type short.

Returns:Type

the reflective representation of type short.

makeTypeVariableback to summary
public TypeVariable<?> makeTypeVariable(String name, FieldTypeSignature[] bounds)

Returns a new type variable declaration. Note that name may be empty (but not null). If bounds is empty, a bound of java.lang.Object is used.

Parameters
name:String

The name of the type variable

bounds:FieldTypeSignature[]

An array of abstract syntax trees representing the upper bound(s) on the type variable being declared

Returns:TypeVariable<?>

a new type variable declaration

Exceptions
NullPointerException:
if any of the actual parameters or any of the elements of bounds are null.
makeVoidback to summary
public Type makeVoid()

Returns the reflective representation of void.

Returns:Type

the reflective representation of void.

makeWildcardback to summary
public WildcardType makeWildcard(FieldTypeSignature[] ubs, FieldTypeSignature[] lbs)

Returns a new wildcard type variable. If ubs is empty, a bound of java.lang.Object is used.

Parameters
ubs:FieldTypeSignature[]

An array of abstract syntax trees representing the upper bound(s) on the type variable being declared

lbs:FieldTypeSignature[]

An array of abstract syntax trees representing the lower bound(s) on the type variable being declared

Returns:WildcardType

a new wildcard type variable

Exceptions
NullPointerException:
if any of the actual parameters or any of the elements of ubs or lbs are null