0N/A/*
2362N/A * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.reflect.generics.factory;
0N/A
0N/Aimport java.lang.reflect.ParameterizedType;
0N/Aimport java.lang.reflect.Type;
0N/Aimport java.lang.reflect.TypeVariable;
0N/Aimport java.lang.reflect.WildcardType;
0N/Aimport sun.reflect.generics.tree.FieldTypeSignature;
0N/A
0N/A/**
0N/A * A factory interface for reflective objects representing generic types.
0N/A * Implementors (such as core reflection or JDI, or possibly javadoc
0N/A * will manufacture instances of (potentially) different classes
0N/A * in response to invocations of the methods described here.
0N/A * <p> The intent is that reflective systems use these factories to
0N/A * produce generic type information on demand.
0N/A * Certain components of such reflective systems can be independent
0N/A * of a specific implementation by using this interface. For example,
0N/A * repositories of generic type information are initialized with a
0N/A * factory conforming to this interface, and use it to generate the
0N/A * tpe information they are required to provide. As a result, such
0N/A * repository code can be shared across different reflective systems.
0N/A */
0N/Apublic interface GenericsFactory {
0N/A /**
0N/A * Returns a new type variable declaration. Note that <tt>name</tt>
0N/A * may be empty (but not <tt>null</tt>). If <tt>bounds</tt> is
0N/A * empty, a bound of <tt>java.lang.Object</tt> is used.
0N/A * @param name The name of the type variable
0N/A * @param bounds An array of abstract syntax trees representing
0N/A * the upper bound(s) on the type variable being declared
0N/A * @return a new type variable declaration
0N/A * @throws NullPointerException - if any of the actual parameters
0N/A * or any of the elements of <tt>bounds</tt> are <tt>null</tt>.
0N/A */
0N/A TypeVariable<?> makeTypeVariable(String name,
0N/A FieldTypeSignature[] bounds);
0N/A /**
0N/A * Return an instance of the <tt>ParameterizedType</tt> interface
0N/A * that corresponds to a generic type instantiation of the
0N/A * generic declaration <tt>declaration</tt> with actual type arguments
0N/A * <tt>typeArgs</tt>.
0N/A * If <tt>owner</tt> is <tt>null</tt>, the declaring class of
0N/A * <tt>declaration</tt> is used as the owner of this parameterized
0N/A * type.
0N/A * <p> This method throws a MalformedParameterizedTypeException
0N/A * under the following circumstances:
0N/A * If the type declaration does not represent a generic declaration
0N/A * (i.e., it is not an instance of <tt>GenericDeclaration</tt>).
0N/A * If the number of actual type arguments (i.e., the size of the
0N/A * array <tt>typeArgs</tt>) does not correspond to the number of
0N/A * formal type arguments.
0N/A * If any of the actual type arguments is not an instance of the
0N/A * bounds on the corresponding formal.
0N/A * @param declaration - the generic type declaration that is to be
0N/A * instantiated
0N/A * @param typeArgs - the list of actual type arguments
0N/A * @return - a parameterized type representing the instantiation
0N/A * of the declaration with the actual type arguments
0N/A * @throws MalformedParameterizedTypeException - if the instantiation
0N/A * is invalid
0N/A * @throws NullPointerException - if any of <tt>declaration</tt>
0N/A * , <tt>typeArgs</tt>
0N/A * or any of the elements of <tt>typeArgs</tt> are <tt>null</tt>
0N/A */
0N/A ParameterizedType makeParameterizedType(Type declaration,
0N/A Type[] typeArgs,
0N/A Type owner);
0N/A
0N/A /**
0N/A * Returns the type variable with name <tt>name</tt>, if such
0N/A * a type variable is declared in the
0N/A * scope used to create this factory.
0N/A * Returns <tt>null</tt> otherwise.
0N/A * @param name - the name of the type variable to search for
0N/A * @return - the type variable with name <tt>name</tt>, or <tt>null</tt>
0N/A * @throws NullPointerException - if any of actual parameters are
0N/A * <tt>null</tt>
0N/A */
0N/A TypeVariable<?> findTypeVariable(String name);
0N/A
0N/A /**
0N/A * Returns a new wildcard type variable. If
0N/A * <tt>ubs</tt> is empty, a bound of <tt>java.lang.Object</tt> is used.
0N/A * @param ubs An array of abstract syntax trees representing
0N/A * the upper bound(s) on the type variable being declared
0N/A * @param lbs An array of abstract syntax trees representing
0N/A * the lower bound(s) on the type variable being declared
0N/A * @return a new wildcard type variable
0N/A * @throws NullPointerException - if any of the actual parameters
0N/A * or any of the elements of <tt>ubs</tt> or <tt>lbs</tt>are
0N/A * <tt>null</tt>
0N/A */
0N/A WildcardType makeWildcard(FieldTypeSignature[] ubs,
0N/A FieldTypeSignature[] lbs);
0N/A
0N/A Type makeNamedType(String name);
0N/A
0N/A /**
0N/A * Returns a (possibly generic) array type.
0N/A * If the component type is a parameterized type, it must
0N/A * only have unbounded wildcard arguemnts, otherwise
0N/A * a MalformedParameterizedTypeException is thrown.
0N/A * @param componentType - the component type of the array
0N/A * @return a (possibly generic) array type.
0N/A * @throws MalformedParameterizedTypeException if <tt>componentType</tt>
0N/A * is a parameterized type with non-wildcard type arguments
0N/A * @throws NullPointerException - if any of the actual parameters
0N/A * are <tt>null</tt>
0N/A */
0N/A Type makeArrayType(Type componentType);
0N/A
0N/A /**
0N/A * Returns the reflective representation of type <tt>byte</tt>.
0N/A * @return the reflective representation of type <tt>byte</tt>.
0N/A */
0N/A Type makeByte();
0N/A
0N/A /**
0N/A * Returns the reflective representation of type <tt>boolean</tt>.
0N/A * @return the reflective representation of type <tt>boolean</tt>.
0N/A */
0N/A Type makeBool();
0N/A
0N/A /**
0N/A * Returns the reflective representation of type <tt>short</tt>.
0N/A * @return the reflective representation of type <tt>short</tt>.
0N/A */
0N/A Type makeShort();
0N/A
0N/A /**
0N/A * Returns the reflective representation of type <tt>char</tt>.
0N/A * @return the reflective representation of type <tt>char</tt>.
0N/A */
0N/A Type makeChar();
0N/A
0N/A /**
0N/A * Returns the reflective representation of type <tt>int</tt>.
0N/A * @return the reflective representation of type <tt>int</tt>.
0N/A */
0N/A Type makeInt();
0N/A
0N/A /**
0N/A * Returns the reflective representation of type <tt>long</tt>.
0N/A * @return the reflective representation of type <tt>long</tt>.
0N/A */
0N/A Type makeLong();
0N/A
0N/A /**
0N/A * Returns the reflective representation of type <tt>float</tt>.
0N/A * @return the reflective representation of type <tt>float</tt>.
0N/A */
0N/A Type makeFloat();
0N/A
0N/A /**
0N/A * Returns the reflective representation of type <tt>double</tt>.
0N/A * @return the reflective representation of type <tt>double</tt>.
0N/A */
0N/A Type makeDouble();
0N/A
0N/A /**
0N/A * Returns the reflective representation of <tt>void</tt>.
0N/A * @return the reflective representation of <tt>void</tt>.
0N/A */
0N/A Type makeVoid();
0N/A}