KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > lang > reflect > TypeVariable


1 /*
2  * @(#)TypeVariable.java 1.3 04/01/12
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.lang.reflect;
9
10 /**
11  * TypeVariable is the common superinterface for type variables of kinds.
12  * A type variable is created the first time it is needed by a reflective
13  * method, as specified in this package. If a type variable t is referenced
14  * by a type (i.e, class, interface or annotation type) T, and T is declared
15  * by the nth enclosing class of T (see JLS 8.1.2), then the creation of t
16  * requires the resolution (see JVMS 5) of the ith enclosing class of T,
17  * for i = 0 to n, inclusive. Creating a type variable must not cause the
18  * creation of its bounds. Repeated creation of a type variable has no effect.
19  *
20  * <p>Multiple objects may be instantiated at run-time to
21  * represent a given type variable. Even though a type variable is
22  * created only once, this does not imply any requirement to cache
23  * instances representing the type variable. However, all instances
24  * representing a type variable must be equal() to each other.
25  * As a consequence, users of type variables must not rely on the identity
26  * of instances of classes implementing this interface.
27  *
28  * <p>The type parameter D represents the type of generic declaration
29  * that declared the underlying type variable.
30  *
31  * @since 1.5
32  */

33 public interface TypeVariable<D extends GenericDeclaration JavaDoc> extends Type JavaDoc {
34     /**
35      * Returns an array of <tt>Type</tt> objects representing the
36      * upper bound(s) of this type variable. Note that if no upper bound is
37      * explicitly declared, the upper bound is <tt>Object</tt>.
38      *
39      * <p>For each upper bound B: <ul> <li>if B is a parameterized
40      * type or a type variable, it is created, (see {@link
41      * java.lang.reflect.ParameterizedType ParameterizedType} for the
42      * details of the creation process for parameterized types).
43      * <li>Otherwise, B is resolved. </ul>
44      *
45      * @throws TypeNotPresentException if any of the
46      * bounds refers to a non-existent type declaration
47      * @throws MalformedParameterizedTypeException if any of the
48      * bounds refer to a parameterized type that cannot be instantiated
49      * for any reason
50      * @return an array of <tt>Type</tt>s representing the upper
51      * bound(s) of this type variable
52     */

53     Type JavaDoc[] getBounds();
54
55     /**
56      * Returns the <tt>GenericDeclaration</tt> object representing the
57      * generic declaration declared this type variable.
58      *
59      * @return the generic declaration declared for this type variable.
60      *
61      * @since 1.5
62      */

63     D getGenericDeclaration();
64
65     /**
66      * Returns the name of this type variable, as it occurs in the source code.
67      *
68      * @return the name of this type variable, as it appears in the source code
69      */

70     String JavaDoc getName();
71 }
72
73
Popular Tags