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. package java.lang.reflect;
  8. /**
  9. * TypeVariable is the common superinterface for type variables of kinds.
  10. * A type variable is created the first time it is needed by a reflective
  11. * method, as specified in this package. If a type variable t is referenced
  12. * by a type (i.e, class, interface or annotation type) T, and T is declared
  13. * by the nth enclosing class of T (see JLS 8.1.2), then the creation of t
  14. * requires the resolution (see JVMS 5) of the ith enclosing class of T,
  15. * for i = 0 to n, inclusive. Creating a type variable must not cause the
  16. * creation of its bounds. Repeated creation of a type variable has no effect.
  17. *
  18. * <p>Multiple objects may be instantiated at run-time to
  19. * represent a given type variable. Even though a type variable is
  20. * created only once, this does not imply any requirement to cache
  21. * instances representing the type variable. However, all instances
  22. * representing a type variable must be equal() to each other.
  23. * As a consequence, users of type variables must not rely on the identity
  24. * of instances of classes implementing this interface.
  25. *
  26. * <p>The type parameter D represents the type of generic declaration
  27. * that declared the underlying type variable.
  28. *
  29. * @since 1.5
  30. */
  31. public interface TypeVariable<D extends GenericDeclaration> extends Type {
  32. /**
  33. * Returns an array of <tt>Type</tt> objects representing the
  34. * upper bound(s) of this type variable. Note that if no upper bound is
  35. * explicitly declared, the upper bound is <tt>Object</tt>.
  36. *
  37. * <p>For each upper bound B: <ul> <li>if B is a parameterized
  38. * type or a type variable, it is created, (see {@link
  39. * java.lang.reflect.ParameterizedType ParameterizedType} for the
  40. * details of the creation process for parameterized types).
  41. * <li>Otherwise, B is resolved. </ul>
  42. *
  43. * @throws TypeNotPresentException if any of the
  44. * bounds refers to a non-existent type declaration
  45. * @throws MalformedParameterizedTypeException if any of the
  46. * bounds refer to a parameterized type that cannot be instantiated
  47. * for any reason
  48. * @return an array of <tt>Type</tt>s representing the upper
  49. * bound(s) of this type variable
  50. */
  51. Type[] getBounds();
  52. /**
  53. * Returns the <tt>GenericDeclaration</tt> object representing the
  54. * generic declaration declared this type variable.
  55. *
  56. * @return the generic declaration declared for this type variable.
  57. *
  58. * @since 1.5
  59. */
  60. D getGenericDeclaration();
  61. /**
  62. * Returns the name of this type variable, as it occurs in the source code.
  63. *
  64. * @return the name of this type variable, as it appears in the source code
  65. */
  66. String getName();
  67. }