diff options
Diffstat (limited to 'javax/lang/model/type')
-rw-r--r-- | javax/lang/model/type/ArrayType.java | 59 | ||||
-rw-r--r-- | javax/lang/model/type/ErrorType.java | 51 | ||||
-rw-r--r-- | javax/lang/model/type/ExecutableType.java | 98 | ||||
-rw-r--r-- | javax/lang/model/type/NoType.java | 60 | ||||
-rw-r--r-- | javax/lang/model/type/NullType.java | 50 | ||||
-rw-r--r-- | javax/lang/model/type/PrimitiveType.java | 52 | ||||
-rw-r--r-- | javax/lang/model/type/TypeVariable.java | 87 | ||||
-rw-r--r-- | javax/lang/model/type/TypeVisitor.java | 80 | ||||
-rw-r--r-- | javax/lang/model/type/WildcardType.java | 79 |
9 files changed, 616 insertions, 0 deletions
diff --git a/javax/lang/model/type/ArrayType.java b/javax/lang/model/type/ArrayType.java new file mode 100644 index 000000000..94538bccd --- /dev/null +++ b/javax/lang/model/type/ArrayType.java @@ -0,0 +1,59 @@ +/* ArrayType.java -- Represents an array type. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.lang.model.type; + +/** + * Represents an array type. Multidimensional arrays are + * represented as array types where the component type + * is also an array type. + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.6 + */ +public interface ArrayType + extends ReferenceType +{ + + /** + * Returns the component type of the array. + * + * @return the component type. + */ + TypeMirror getComponentType(); + +} diff --git a/javax/lang/model/type/ErrorType.java b/javax/lang/model/type/ErrorType.java new file mode 100644 index 000000000..34ac7a5e3 --- /dev/null +++ b/javax/lang/model/type/ErrorType.java @@ -0,0 +1,51 @@ +/* ErrorType.java -- Represents a type that can't be modelled. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.lang.model.type; + +/** + * Represents a type that can't be modelled. This may be as + * a result of a number of reasons, such as a missing class file, + * an erroneous source file or a processing error. + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.6 + */ +public interface ErrorType + extends DeclaredType +{ +} diff --git a/javax/lang/model/type/ExecutableType.java b/javax/lang/model/type/ExecutableType.java new file mode 100644 index 000000000..72d81b4b7 --- /dev/null +++ b/javax/lang/model/type/ExecutableType.java @@ -0,0 +1,98 @@ +/* ExecutableType.java -- Represents a method, constructor or initialiser. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.lang.model.type; + +import java.util.List; + +/** + * Represents something which may be executed i.e. a + * constructor, a method or an initialiser. The executable + * is viewed respective to a particular type. As a result, + * any type parameters will be substituted with actual type + * arguments as appropriate. + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.6 + * @see + */ +public interface ExecutableType + extends TypeMirror +{ + + /** + * Returns the types of the formal parameters of this + * executable, or an empty list if the executable takes + * no parameters. For example, {@code doThis(int)} will + * return a list containing a single element, the type + * mirror for {@code int}. + * + * @return the executable's formal parameters. + */ + List<? extends TypeMirror> getParameterTypes(); + + /** + * Returns the return type of the executable. If the + * executable is a constructor or an initialiser, or + * does not return anything, this method will return + * an instance of {@link NoType} with the kind + * {@link TypeKind#VOID}. + * + * @return the return type of this executable. + */ + TypeMirror getReturnType(); + + /** + * Returns the types of any exceptions or other + * {@link Throwable}s mentioned in the {@code throws} + * clause of this executable, or an empty list if there + * are none. + * + * @return the exceptions and other throwables declared + * as thrown by this executable. + */ + List<? extends TypeMirror> getThrownTypes(); + + /** + * Returns the type variables declared by the formal type + * parameters or an empty list if there are none. + * + * @return the type variables declared by this executable. + */ + List<? extends TypeVariable> getTypeVariables(); + +} diff --git a/javax/lang/model/type/NoType.java b/javax/lang/model/type/NoType.java new file mode 100644 index 000000000..7cccc436a --- /dev/null +++ b/javax/lang/model/type/NoType.java @@ -0,0 +1,60 @@ +/* NoType.java -- Represents a pseudo-type used when nothing is appropriate. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.lang.model.type; + +/** + * <p>Represents a pseudo-type used when a {@link TypeMirror} + * needs to be returned, but there is not one suitable.</p> + * <p>Further information is provided by the kind of the + * instance, as follows:</p> + * <ul> + * <li>{@link TypeKind#VOID}; used for method return types.</li> + * <li>{@link TypeKind#PACKAGE}; used for packages.</li> + * <li>{@link TypeKind#NONE}: used when nothing else fits. + * For example, requesting a superclass from + * {@code java.lang.Object}.</li> + * </ul> + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.6 + * @see javax.lang.model.element.ExecutableElement#getReturnType() + */ +public interface NoType + extends TypeMirror +{ +} diff --git a/javax/lang/model/type/NullType.java b/javax/lang/model/type/NullType.java new file mode 100644 index 000000000..53f9819bd --- /dev/null +++ b/javax/lang/model/type/NullType.java @@ -0,0 +1,50 @@ +/* NullType.java -- Represents the null type. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.lang.model.type; + +/** + * Represents the null type i.e. the type of the expression + * {@code null}. + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.6 + */ +public interface NullType + extends ReferenceType +{ +} diff --git a/javax/lang/model/type/PrimitiveType.java b/javax/lang/model/type/PrimitiveType.java new file mode 100644 index 000000000..6586079df --- /dev/null +++ b/javax/lang/model/type/PrimitiveType.java @@ -0,0 +1,52 @@ +/* PrimitiveType.java -- Represents a primitive type. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.lang.model.type; + +/** + * Represents a primitive type such as a {@code byte}, + * {@code boolean}, {@code char}, {@code double}, + * {@code float}, {@code int}, {@code long} or + * {@code short}. + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.6 + */ +public interface PrimitiveType + extends TypeMirror +{ +} diff --git a/javax/lang/model/type/TypeVariable.java b/javax/lang/model/type/TypeVariable.java new file mode 100644 index 000000000..87b308780 --- /dev/null +++ b/javax/lang/model/type/TypeVariable.java @@ -0,0 +1,87 @@ +/* TypeVariable.java -- Represents a type variable. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.lang.model.type; + +import javax.lang.model.element.Element; + +/** + * Represents a type variable. Such variables may be the + * result of an explicitly declared type parameter on + * a type, method or constructor, or be created implicitly + * as a function of capture conversion on a wildcard type + * argument. See chapter 5 of the Java Language Specification. + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.6 + */ +public interface TypeVariable + extends ReferenceType +{ + + /** + * Returns the element which corresponds to this type variable. + * + * @return the element corresponding to this type variable. + */ + Element asElement(); + + /** + * Returns the lower bound of this type variable. While type + * variables can not be given an explicit lower bound, a + * non-trivial lower bound may be produced through capture + * conversion on a wildcard type argument. If this is not the + * case, the lower bound will be the {@link NullType}. + * + * @return the lower bound of this type variable. + */ + TypeMirror getLowerBound(); + + /** + * Returns the upper bound of this type variable. If an + * explicit upper bound was not given, this will return + * {@code java.lang.Object}. Where multiple upper bounds + * are specified, an intersection type is generated and + * represented as an instance of {@link DeclaredType}. + * The supertypes of this may be examined to find the + * actual bounds specified. + * + * @return the upper bound of this type variable. + */ + TypeMirror getUpperBound(); + +} diff --git a/javax/lang/model/type/TypeVisitor.java b/javax/lang/model/type/TypeVisitor.java index ea00f5227..df0c2e5f1 100644 --- a/javax/lang/model/type/TypeVisitor.java +++ b/javax/lang/model/type/TypeVisitor.java @@ -104,4 +104,84 @@ public interface TypeVisitor<R,P> */ R visitDeclared(DeclaredType type, P param); + /** + * Visits an array type. + * + * @param type the array type to visit. + * @param param the additional parameter, specific to the visitor. + * May be {@code null} if permitted by the visitor. + * @return the return value specific to the visitor. + */ + R visitArray(ArrayType type, P param); + + /** + * Visits an error type. + * + * @param type the error type to visit. + * @param param the additional parameter, specific to the visitor. + * May be {@code null} if permitted by the visitor. + * @return the return value specific to the visitor. + */ + R visitError(ErrorType type, P param); + + /** + * Visits an executable type. + * + * @param type the executable type to visit. + * @param param the additional parameter, specific to the visitor. + * May be {@code null} if permitted by the visitor. + * @return the return value specific to the visitor. + */ + R visitExecutable(ExecutableType type, P param); + + /** + * Visits a {@link NoType} instance. + * + * @param type the instance to visit. + * @param param the additional parameter, specific to the visitor. + * May be {@code null} if permitted by the visitor. + * @return the return value specific to the visitor. + */ + R visitNoType(NoType type, P param); + + /** + * Visits the null type. + * + * @param type the type to visit. + * @param param the additional parameter, specific to the visitor. + * May be {@code null} if permitted by the visitor. + * @return the return value specific to the visitor. + */ + R visitNull(NullType type, P param); + + /** + * Visits a primitive type. + * + * @param type the primitive type to visit. + * @param param the additional parameter, specific to the visitor. + * May be {@code null} if permitted by the visitor. + * @return the return value specific to the visitor. + */ + R visitPrimitive(PrimitiveType type, P param); + + /** + * Visits a type variable. + * + * @param type the type variable to visit. + * @param param the additional parameter, specific to the visitor. + * May be {@code null} if permitted by the visitor. + * @return the return value specific to the visitor. + */ + R visitTypeVariable(TypeVariable type, P param); + + /** + * Visits a wildcard type. + * + * @param type the wildcard type to visit. + * @param param the additional parameter, specific to the visitor. + * May be {@code null} if permitted by the visitor. + * @return the return value specific to the visitor. + */ + R visitWildcard(WildcardType type, P param); + } diff --git a/javax/lang/model/type/WildcardType.java b/javax/lang/model/type/WildcardType.java new file mode 100644 index 000000000..20dfd827a --- /dev/null +++ b/javax/lang/model/type/WildcardType.java @@ -0,0 +1,79 @@ +/* WildcardType.java -- Represents a wildcard type argument. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.lang.model.type; + +import javax.lang.model.element.Element; + +/** + * <p>Represents a wildcard type argument, which may take one + * of three forms:</p> + * <ul> + * <li>{@code ?}</li> + * <li>{@code ? extends X}</li> + * <li>{@code ? super Y}</li> + * </ul> + * <p>i.e. it may have no bounds, an upper bound set by + * the {@code extends} clause or a lower bound set by + * the {@code super} clause, but not both.</p> + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.6 + */ +public interface WildcardType + extends TypeMirror +{ + + /** + * Returns the upper bound of this wildcard type, + * as declared by the {@code extends} clause, or + * {@code null} if one wasn't specified. + * + * @return the upper bound. + */ + TypeMirror getExtendsBound(); + + /** + * Returns the lower bound of this wildcard type, + * as declared by the {@code super} clause, or + * {@code null} if one wasn't specified. + * + * @return the upper bound. + */ + TypeMirror getSuperBound(); + +} |