emul/src/main/java/java/lang/reflect/TypeVariable.java
branchreflection
changeset 259 9b0fbf4ec230
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/emul/src/main/java/java/lang/reflect/TypeVariable.java	Tue Dec 04 14:08:19 2012 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +/*
     1.5 + * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package java.lang.reflect;
    1.30 +
    1.31 +/**
    1.32 + * TypeVariable is the common superinterface for type variables of kinds.
    1.33 + * A type variable is created the first time it is needed by a reflective
    1.34 + * method, as specified in this package.  If a type variable t is referenced
    1.35 + * by a type (i.e, class, interface or annotation type) T, and T is declared
    1.36 + * by the nth enclosing class of T (see JLS 8.1.2), then the creation of t
    1.37 + * requires the resolution (see JVMS 5) of the ith enclosing class of T,
    1.38 + * for i = 0 to n, inclusive. Creating a type variable must not cause the
    1.39 + * creation of its bounds. Repeated creation of a type variable has no effect.
    1.40 + *
    1.41 + * <p>Multiple objects may be instantiated at run-time to
    1.42 + * represent a given type variable. Even though a type variable is
    1.43 + * created only once, this does not imply any requirement to cache
    1.44 + * instances representing the type variable. However, all instances
    1.45 + * representing a type variable must be equal() to each other.
    1.46 + * As a consequence, users of type variables must not rely on the identity
    1.47 + * of instances of classes implementing this interface.
    1.48 + *
    1.49 + * @param <D> the type of generic declaration that declared the
    1.50 + * underlying type variable.
    1.51 + *
    1.52 + * @since 1.5
    1.53 + */
    1.54 +public interface TypeVariable<D extends GenericDeclaration> extends Type {
    1.55 +    /**
    1.56 +     * Returns an array of {@code Type} objects representing the
    1.57 +     * upper bound(s) of this type variable.  Note that if no upper bound is
    1.58 +     * explicitly declared, the upper bound is {@code Object}.
    1.59 +     *
    1.60 +     * <p>For each upper bound B: <ul> <li>if B is a parameterized
    1.61 +     * type or a type variable, it is created, (see {@link
    1.62 +     * java.lang.reflect.ParameterizedType ParameterizedType} for the
    1.63 +     * details of the creation process for parameterized types).
    1.64 +     * <li>Otherwise, B is resolved.  </ul>
    1.65 +     *
    1.66 +     * @throws TypeNotPresentException  if any of the
    1.67 +     *     bounds refers to a non-existent type declaration
    1.68 +     * @throws MalformedParameterizedTypeException if any of the
    1.69 +     *     bounds refer to a parameterized type that cannot be instantiated
    1.70 +     *     for any reason
    1.71 +     * @return an array of {@code Type}s representing the upper
    1.72 +     *     bound(s) of this type variable
    1.73 +    */
    1.74 +    Type[] getBounds();
    1.75 +
    1.76 +    /**
    1.77 +     * Returns the {@code GenericDeclaration} object representing the
    1.78 +     * generic declaration declared this type variable.
    1.79 +     *
    1.80 +     * @return the generic declaration declared for this type variable.
    1.81 +     *
    1.82 +     * @since 1.5
    1.83 +     */
    1.84 +    D getGenericDeclaration();
    1.85 +
    1.86 +    /**
    1.87 +     * Returns the name of this type variable, as it occurs in the source code.
    1.88 +     *
    1.89 +     * @return the name of this type variable, as it appears in the source code
    1.90 +     */
    1.91 +    String getName();
    1.92 +}