feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import java.util.Map;
import javax.lang.model.type.DeclaredType;
/**
* Represents an annotation. An annotation associates a value with
* each element of an annotation type.
*
* <p> Annotations should be compared using the {@code equals}
* method. There is no guarantee that any particular annotation will
* always be represented by the same object.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface AnnotationMirror {
/**
* Returns the type of this annotation.
*
* @return the type of this annotation
*/
DeclaredType getAnnotationType();
/**
* Returns the values of this annotation's elements.
* This is returned in the form of a map that associates elements
* with their corresponding values.
* Only those elements with values explicitly present in the
* annotation are included, not those that are implicitly assuming
* their default values.
* The order of the map matches the order in which the
* values appear in the annotation's source.
*
* <p>Note that an annotation mirror of a marker annotation type
* will by definition have an empty map.
*
* <p>To fill in default values, use {@link
* javax.lang.model.util.Elements#getElementValuesWithDefaults
* getElementValuesWithDefaults}.
*
* @return the values of this annotation's elements,
* or an empty map if there are none
*/
Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues();
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
/**
* Represents a value of an annotation type element.
* A value is of one of the following types:
* <ul><li> a wrapper class (such as {@link Integer}) for a primitive type
* <li> {@code String}
* <li> {@code TypeMirror}
* <li> {@code VariableElement} (representing an enum constant)
* <li> {@code AnnotationMirror}
* <li> {@code List<? extends AnnotationValue>}
* (representing the elements, in declared order, if the value is an array)
* </ul>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface AnnotationValue {
/**
* Returns the value.
*
* @return the value
*/
Object getValue();
/**
* Returns a string representation of this value.
* This is returned in a form suitable for representing this value
* in the source code of an annotation.
*
* @return a string representation of this value
*/
String toString();
/**
* Applies a visitor to this value.
*
* @param <R> the return type of the visitor's methods
* @param <P> the type of the additional parameter to the visitor's methods
* @param v the visitor operating on this value
* @param p additional parameter to the visitor
* @return a visitor-specified result
*/
<R, P> R accept(AnnotationValueVisitor<R, P> v, P p);
}

View File

@@ -0,0 +1,214 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.TypeMirror;
/**
* A visitor of the values of annotation type elements, using a
* variant of the visitor design pattern. Unlike a standard visitor
* which dispatches based on the concrete type of a member of a type
* hierarchy, this visitor dispatches based on the type of data
* stored; there are no distinct subclasses for storing, for example,
* {@code boolean} values versus {@code int} values. Classes
* implementing this interface are used to operate on a value when the
* type of that value is unknown at compile time. When a visitor is
* passed to a value's {@link AnnotationValue#accept accept} method,
* the <tt>visit<i>XYZ</i></tt> method applicable to that value is
* invoked.
*
* <p> Classes implementing this interface may or may not throw a
* {@code NullPointerException} if the additional parameter {@code p}
* is {@code null}; see documentation of the implementing class for
* details.
*
* <p> <b>WARNING:</b> It is possible that methods will be added to
* this interface to accommodate new, currently unknown, language
* structures added to future versions of the Java&trade; programming
* language. Therefore, visitor classes directly implementing this
* interface may be source incompatible with future versions of the
* platform. To avoid this source incompatibility, visitor
* implementations are encouraged to instead extend the appropriate
* abstract visitor class that implements this interface. However, an
* API should generally use this visitor interface as the type for
* parameters, return type, etc. rather than one of the abstract
* classes.
*
* <p>Note that methods to accommodate new language constructs could
* be added in a source <em>compatible</em> way if they were added as
* <em>default methods</em>. However, default methods are only
* available on Java SE 8 and higher releases and the {@code
* javax.lang.model.*} packages bundled in Java SE 8 are required to
* also be runnable on Java SE 7. Therefore, default methods
* <em>cannot</em> be used when extending {@code javax.lang.model.*}
* to cover Java SE 8 language features. However, default methods may
* be used in subsequent revisions of the {@code javax.lang.model.*}
* packages that are only required to run on Java SE 8 and higher
* platform versions.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface AnnotationValueVisitor<R, P> {
/**
* Visits an annotation value.
* @param av the value to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visit(AnnotationValue av, P p);
/**
* A convenience method equivalent to {@code v.visit(av, null)}.
* @param av the value to visit
* @return a visitor-specified result
*/
R visit(AnnotationValue av);
/**
* Visits a {@code boolean} value in an annotation.
* @param b the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitBoolean(boolean b, P p);
/**
* Visits a {@code byte} value in an annotation.
* @param b the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitByte(byte b, P p);
/**
* Visits a {@code char} value in an annotation.
* @param c the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitChar(char c, P p);
/**
* Visits a {@code double} value in an annotation.
* @param d the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitDouble(double d, P p);
/**
* Visits a {@code float} value in an annotation.
* @param f the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitFloat(float f, P p);
/**
* Visits an {@code int} value in an annotation.
* @param i the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitInt(int i, P p);
/**
* Visits a {@code long} value in an annotation.
* @param i the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitLong(long i, P p);
/**
* Visits a {@code short} value in an annotation.
* @param s the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitShort(short s, P p);
/**
* Visits a string value in an annotation.
* @param s the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitString(String s, P p);
/**
* Visits a type value in an annotation.
* @param t the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitType(TypeMirror t, P p);
/**
* Visits an {@code enum} value in an annotation.
* @param c the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitEnumConstant(VariableElement c, P p);
/**
* Visits an annotation value in an annotation.
* @param a the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitAnnotation(AnnotationMirror a, P p);
/**
* Visits an array value in an annotation.
* @param vals the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitArray(List<? extends AnnotationValue> vals, P p);
/**
* Visits an unknown kind of annotation value.
* This can occur if the language evolves and new kinds
* of value can be stored in an annotation.
* @param av the unknown value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
* @throws UnknownAnnotationValueException
* a visitor implementation may optionally throw this exception
*/
R visitUnknown(AnnotationValue av, P p);
}

View File

@@ -0,0 +1,246 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationTypeMismatchException;
import java.lang.annotation.IncompleteAnnotationException;
import java.util.List;
import java.util.Set;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
/**
* Represents a program element such as a package, class, or method.
* Each element represents a static, language-level construct
* (and not, for example, a runtime construct of the virtual machine).
*
* <p> Elements should be compared using the {@link #equals(Object)}
* method. There is no guarantee that any particular element will
* always be represented by the same object.
*
* <p> To implement operations based on the class of an {@code
* Element} object, either use a {@linkplain ElementVisitor visitor} or
* use the result of the {@link #getKind} method. Using {@code
* instanceof} is <em>not</em> necessarily a reliable idiom for
* determining the effective class of an object in this modeling
* hierarchy since an implementation may choose to have a single object
* implement multiple {@code Element} subinterfaces.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see Elements
* @see TypeMirror
* @since 1.6
*/
public interface Element extends javax.lang.model.AnnotatedConstruct {
/**
* Returns the type defined by this element.
*
* <p> A generic element defines a family of types, not just one.
* If this is a generic element, a <i>prototypical</i> type is
* returned. This is the element's invocation on the
* type variables corresponding to its own formal type parameters.
* For example,
* for the generic class element {@code C<N extends Number>},
* the parameterized type {@code C<N>} is returned.
* The {@link Types} utility interface has more general methods
* for obtaining the full range of types defined by an element.
*
* @see Types
*
* @return the type defined by this element
*/
TypeMirror asType();
/**
* Returns the {@code kind} of this element.
*
* @return the kind of this element
*/
ElementKind getKind();
/**
* Returns the modifiers of this element, excluding annotations.
* Implicit modifiers, such as the {@code public} and {@code static}
* modifiers of interface members, are included.
*
* @return the modifiers of this element, or an empty set if there are none
*/
Set<Modifier> getModifiers();
/**
* Returns the simple (unqualified) name of this element. The
* name of a generic type does not include any reference to its
* formal type parameters.
*
* For example, the simple name of the type element {@code
* java.util.Set<E>} is {@code "Set"}.
*
* If this element represents an unnamed {@linkplain
* PackageElement#getSimpleName package}, an empty name is
* returned.
*
* If it represents a {@linkplain ExecutableElement#getSimpleName
* constructor}, the name "{@code <init>}" is returned. If it
* represents a {@linkplain ExecutableElement#getSimpleName static
* initializer}, the name "{@code <clinit>}" is returned.
*
* If it represents an {@linkplain TypeElement#getSimpleName
* anonymous class} or {@linkplain ExecutableElement#getSimpleName
* instance initializer}, an empty name is returned.
*
* @return the simple name of this element
* @see PackageElement#getSimpleName
* @see ExecutableElement#getSimpleName
* @see TypeElement#getSimpleName
* @see VariableElement#getSimpleName
*/
Name getSimpleName();
/**
* Returns the innermost element
* within which this element is, loosely speaking, enclosed.
* <ul>
* <li> If this element is one whose declaration is lexically enclosed
* immediately within the declaration of another element, that other
* element is returned.
*
* <li> If this is a {@linkplain TypeElement#getEnclosingElement
* top-level type}, its package is returned.
*
* <li> If this is a {@linkplain
* PackageElement#getEnclosingElement package}, {@code null} is
* returned.
*
* <li> If this is a {@linkplain
* TypeParameterElement#getEnclosingElement type parameter},
* {@linkplain TypeParameterElement#getGenericElement the
* generic element} of the type parameter is returned.
*
* <li> If this is a {@linkplain
* VariableElement#getEnclosingElement method or constructor
* parameter}, {@linkplain ExecutableElement the executable
* element} which declares the parameter is returned.
*
* </ul>
*
* @return the enclosing element, or {@code null} if there is none
* @see Elements#getPackageOf
*/
Element getEnclosingElement();
/**
* Returns the elements that are, loosely speaking, directly
* enclosed by this element.
*
* A {@linkplain TypeElement#getEnclosedElements class or
* interface} is considered to enclose the fields, methods,
* constructors, and member types that it directly declares.
*
* A {@linkplain PackageElement#getEnclosedElements package}
* encloses the top-level classes and interfaces within it, but is
* not considered to enclose subpackages.
*
* Other kinds of elements are not currently considered to enclose
* any elements; however, that may change as this API or the
* programming language evolves.
*
* <p>Note that elements of certain kinds can be isolated using
* methods in {@link ElementFilter}.
*
* @return the enclosed elements, or an empty list if none
* @see PackageElement#getEnclosedElements
* @see TypeElement#getEnclosedElements
* @see Elements#getAllMembers
* @jls 8.8.9 Default Constructor
* @jls 8.9 Enums
*/
List<? extends Element> getEnclosedElements();
/**
* Returns {@code true} if the argument represents the same
* element as {@code this}, or {@code false} otherwise.
*
* <p>Note that the identity of an element involves implicit state
* not directly accessible from the element's methods, including
* state about the presence of unrelated types. Element objects
* created by different implementations of these interfaces should
* <i>not</i> be expected to be equal even if &quot;the same&quot;
* element is being modeled; this is analogous to the inequality
* of {@code Class} objects for the same class file loaded through
* different class loaders.
*
* @param obj the object to be compared with this element
* @return {@code true} if the specified object represents the same
* element as this
*/
@Override
boolean equals(Object obj);
/**
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
*
* @see #equals
*/
@Override
int hashCode();
/**
* {@inheritDoc}
*
* <p> To get inherited annotations as well, use {@link
* Elements#getAllAnnotationMirrors(Element)
* getAllAnnotationMirrors}.
*
* @since 1.6
*/
@Override
List<? extends AnnotationMirror> getAnnotationMirrors();
/**
* {@inheritDoc}
* @since 1.6
*/
@Override
<A extends Annotation> A getAnnotation(Class<A> annotationType);
/**
* Applies a visitor to this element.
*
* @param <R> the return type of the visitor's methods
* @param <P> the type of the additional parameter to the visitor's methods
* @param v the visitor operating on this element
* @param p additional parameter to the visitor
* @return a visitor-specified result
*/
<R, P> R accept(ElementVisitor<R, P> v, P p);
}

View File

@@ -0,0 +1,129 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
/**
* The {@code kind} of an element.
*
* <p>Note that it is possible additional element kinds will be added
* to accommodate new, currently unknown, language structures added to
* future versions of the Java&trade; programming language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see Element
* @since 1.6
*/
public enum ElementKind {
/** A package. */
PACKAGE,
// Declared types
/** An enum type. */
ENUM,
/** A class not described by a more specific kind (like {@code ENUM}). */
CLASS,
/** An annotation type. */
ANNOTATION_TYPE,
/**
* An interface not described by a more specific kind (like
* {@code ANNOTATION_TYPE}).
*/
INTERFACE,
// Variables
/** An enum constant. */
ENUM_CONSTANT,
/**
* A field not described by a more specific kind (like
* {@code ENUM_CONSTANT}).
*/
FIELD,
/** A parameter of a method or constructor. */
PARAMETER,
/** A local variable. */
LOCAL_VARIABLE,
/** A parameter of an exception handler. */
EXCEPTION_PARAMETER,
// Executables
/** A method. */
METHOD,
/** A constructor. */
CONSTRUCTOR,
/** A static initializer. */
STATIC_INIT,
/** An instance initializer. */
INSTANCE_INIT,
/** A type parameter. */
TYPE_PARAMETER,
/**
* An implementation-reserved element. This is not the element
* you are looking for.
*/
OTHER,
/**
* A resource variable.
* @since 1.7
*/
RESOURCE_VARIABLE;
/**
* Returns {@code true} if this is a kind of class:
* either {@code CLASS} or {@code ENUM}.
*
* @return {@code true} if this is a kind of class
*/
public boolean isClass() {
return this == CLASS || this == ENUM;
}
/**
* Returns {@code true} if this is a kind of interface:
* either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
*
* @return {@code true} if this is a kind of interface
*/
public boolean isInterface() {
return this == INTERFACE || this == ANNOTATION_TYPE;
}
/**
* Returns {@code true} if this is a kind of field:
* either {@code FIELD} or {@code ENUM_CONSTANT}.
*
* @return {@code true} if this is a kind of field
*/
public boolean isField() {
return this == FIELD || this == ENUM_CONSTANT;
}
}

View File

@@ -0,0 +1,148 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import javax.lang.model.util.*;
/**
* A visitor of program elements, in the style of the visitor design
* pattern. Classes implementing this interface are used to operate
* on an element when the kind of element is unknown at compile time.
* When a visitor is passed to an element's {@link Element#accept
* accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable
* to that element is invoked.
*
* <p> Classes implementing this interface may or may not throw a
* {@code NullPointerException} if the additional parameter {@code p}
* is {@code null}; see documentation of the implementing class for
* details.
*
* <p> <b>WARNING:</b> It is possible that methods will be added to
* this interface to accommodate new, currently unknown, language
* structures added to future versions of the Java&trade; programming
* language. Therefore, visitor classes directly implementing this
* interface may be source incompatible with future versions of the
* platform. To avoid this source incompatibility, visitor
* implementations are encouraged to instead extend the appropriate
* abstract visitor class that implements this interface. However, an
* API should generally use this visitor interface as the type for
* parameters, return type, etc. rather than one of the abstract
* classes.
*
* <p>Note that methods to accommodate new language constructs could
* be added in a source <em>compatible</em> way if they were added as
* <em>default methods</em>. However, default methods are only
* available on Java SE 8 and higher releases and the {@code
* javax.lang.model.*} packages bundled in Java SE 8 are required to
* also be runnable on Java SE 7. Therefore, default methods
* <em>cannot</em> be used when extending {@code javax.lang.model.*}
* to cover Java SE 8 language features. However, default methods may
* be used in subsequent revisions of the {@code javax.lang.model.*}
* packages that are only required to run on Java SE 8 and higher
* platform versions.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see AbstractElementVisitor6
* @see AbstractElementVisitor7
* @since 1.6
*/
public interface ElementVisitor<R, P> {
/**
* Visits an element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visit(Element e, P p);
/**
* A convenience method equivalent to {@code v.visit(e, null)}.
* @param e the element to visit
* @return a visitor-specified result
*/
R visit(Element e);
/**
* Visits a package element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitPackage(PackageElement e, P p);
/**
* Visits a type element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitType(TypeElement e, P p);
/**
* Visits a variable element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitVariable(VariableElement e, P p);
/**
* Visits an executable element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitExecutable(ExecutableElement e, P p);
/**
* Visits a type parameter element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitTypeParameter(TypeParameterElement e, P p);
/**
* Visits an unknown kind of element.
* This can occur if the language evolves and new kinds
* of elements are added to the {@code Element} hierarchy.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @throws UnknownElementException
* a visitor implementation may optionally throw this exception
*/
R visitUnknown(Element e, P p);
}

View File

@@ -0,0 +1,141 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.*;
/**
* Represents a method, constructor, or initializer (static or
* instance) of a class or interface, including annotation type
* elements.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see ExecutableType
* @since 1.6
*/
public interface ExecutableElement extends Element, Parameterizable {
/**
* Returns the formal type parameters of this executable
* in declaration order.
*
* @return the formal type parameters, or an empty list
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
/**
* Returns the return type of this executable.
* Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
* if this executable is not a method, or is a method that does not
* return a value.
*
* @return the return type of this executable
*/
TypeMirror getReturnType();
/**
* Returns the formal parameters of this executable.
* They are returned in declaration order.
*
* @return the formal parameters,
* or an empty list if there are none
*/
List<? extends VariableElement> getParameters();
/**
* Returns the receiver type of this executable,
* or {@link javax.lang.model.type.NoType NoType} with
* kind {@link javax.lang.model.type.TypeKind#NONE NONE}
* if the executable has no receiver type.
*
* An executable which is an instance method, or a constructor of an
* inner class, has a receiver type derived from the {@linkplain
* #getEnclosingElement declaring type}.
*
* An executable which is a static method, or a constructor of a
* non-inner class, or an initializer (static or instance), has no
* receiver type.
*
* @return the receiver type of this executable
* @since 1.8
*/
TypeMirror getReceiverType();
/**
* Returns {@code true} if this method or constructor accepts a variable
* number of arguments and returns {@code false} otherwise.
*
* @return {@code true} if this method or constructor accepts a variable
* number of arguments and {@code false} otherwise
*/
boolean isVarArgs();
/**
* Returns {@code true} if this method is a default method and
* returns {@code false} otherwise.
*
* @return {@code true} if this method is a default method and
* {@code false} otherwise
* @since 1.8
*/
boolean isDefault();
/**
* Returns the exceptions and other throwables listed in this
* method or constructor's {@code throws} clause in declaration
* order.
*
* @return the exceptions and other throwables listed in the
* {@code throws} clause, or an empty list if there are none
*/
List<? extends TypeMirror> getThrownTypes();
/**
* Returns the default value if this executable is an annotation
* type element. Returns {@code null} if this method is not an
* annotation type element, or if it is an annotation type element
* with no default value.
*
* @return the default value, or {@code null} if none
*/
AnnotationValue getDefaultValue();
/**
* Returns the simple name of a constructor, method, or
* initializer. For a constructor, the name {@code "<init>"} is
* returned, for a static initializer, the name {@code "<clinit>"}
* is returned, and for an anonymous class or instance
* initializer, an empty name is returned.
*
* @return the simple name of a constructor, method, or
* initializer
*/
@Override
Name getSimpleName();
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
/**
* Represents a modifier on a program element such
* as a class, method, or field.
*
* <p>Not all modifiers are applicable to all kinds of elements.
* When two or more modifiers appear in the source code of an element
* then it is customary, though not required, that they appear in the same
* order as the constants listed in the detail section below.
*
* <p>Note that it is possible additional modifiers will be added in
* future versions of the platform.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public enum Modifier {
// See JLS sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1.
// java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.
/** The modifier {@code public} */ PUBLIC,
/** The modifier {@code protected} */ PROTECTED,
/** The modifier {@code private} */ PRIVATE,
/** The modifier {@code abstract} */ ABSTRACT,
/**
* The modifier {@code default}
* @since 1.8
*/
DEFAULT,
/** The modifier {@code static} */ STATIC,
/** The modifier {@code final} */ FINAL,
/** The modifier {@code transient} */ TRANSIENT,
/** The modifier {@code volatile} */ VOLATILE,
/** The modifier {@code synchronized} */ SYNCHRONIZED,
/** The modifier {@code native} */ NATIVE,
/** The modifier {@code strictfp} */ STRICTFP;
/**
* Returns this modifier's name in lowercase.
*/
public String toString() {
return name().toLowerCase(java.util.Locale.US);
}
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
/**
* An immutable sequence of characters. When created by the same
* implementation, objects implementing this interface must obey the
* general {@linkplain Object#equals equals contract} when compared
* with each other. Therefore, {@code Name} objects from the same
* implementation are usable in collections while {@code Name}s from
* different implementations may not work properly in collections.
*
* <p>An empty {@code Name} has a length of zero.
*
* <p>In the context of {@linkplain
* javax.annotation.processing.ProcessingEnvironment annotation
* processing}, the guarantees for "the same" implementation must
* include contexts where the {@linkplain javax.annotation.processing
* API mediated} side effects of {@linkplain
* javax.annotation.processing.Processor processors} could be visible
* to each other, including successive annotation processing
* {@linkplain javax.annotation.processing.RoundEnvironment rounds}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see javax.lang.model.util.Elements#getName
* @since 1.6
*/
public interface Name extends CharSequence {
/**
* Returns {@code true} if the argument represents the same
* name as {@code this}, and {@code false} otherwise.
*
* <p>Note that the identity of a {@code Name} is a function both
* of its content in terms of a sequence of characters as well as
* the implementation which created it.
*
* @param obj the object to be compared with this element
* @return {@code true} if the specified object represents the same
* name as this
* @see Element#equals
*/
boolean equals(Object obj);
/**
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
*
* @see #equals
*/
int hashCode();
/**
* Compares this name to the specified {@code CharSequence}. The result
* is {@code true} if and only if this name represents the same sequence
* of {@code char} values as the specified sequence.
*
* @return {@code true} if this name represents the same sequence
* of {@code char} values as the specified sequence, {@code false}
* otherwise
*
* @param cs The sequence to compare this name against
* @see String#contentEquals(CharSequence)
*/
boolean contentEquals(CharSequence cs);
}

View File

@@ -0,0 +1,115 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
/**
* The <i>nesting kind</i> of a type element.
* Type elements come in four varieties:
* top-level, member, local, and anonymous.
* <i>Nesting kind</i> is a non-standard term used here to denote this
* classification.
*
* <p>Note that it is possible additional nesting kinds will be added
* in future versions of the platform.
*
* <p><b>Example:</b> The classes below are annotated with their nesting kind.
* <blockquote><pre>
*
* import java.lang.annotation.*;
* import static java.lang.annotation.RetentionPolicy.*;
* import javax.lang.model.element.*;
* import static javax.lang.model.element.NestingKind.*;
*
* &#64;Nesting(TOP_LEVEL)
* public class NestingExamples {
* &#64;Nesting(MEMBER)
* static class MemberClass1{}
*
* &#64;Nesting(MEMBER)
* class MemberClass2{}
*
* public static void main(String... argv) {
* &#64;Nesting(LOCAL)
* class LocalClass{};
*
* Class&lt;?&gt;[] classes = {
* NestingExamples.class,
* MemberClass1.class,
* MemberClass2.class,
* LocalClass.class
* };
*
* for(Class&lt;?&gt; clazz : classes) {
* System.out.format("%s is %s%n",
* clazz.getName(),
* clazz.getAnnotation(Nesting.class).value());
* }
* }
* }
*
* &#64;Retention(RUNTIME)
* &#64;interface Nesting {
* NestingKind value();
* }
* </pre></blockquote>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public enum NestingKind {
/**
* A top-level type, not contained within another type.
*/
TOP_LEVEL,
/**
* A type that is a named member of another type.
*/
MEMBER,
/**
* A named type declared within a construct other than a type.
*/
LOCAL,
/**
* A type without a name.
*/
ANONYMOUS;
/**
* Does this constant correspond to a nested type element?
* A <i>nested</i> type element is any that is not top-level.
* An <i>inner</i> type element is any nested type element that
* is not {@linkplain Modifier#STATIC static}.
* @return whether or not the constant is nested
*/
public boolean isNested() {
return this != TOP_LEVEL;
}
}

View File

@@ -0,0 +1,92 @@
/*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import java.util.List;
/**
* Represents a package program element. Provides access to information
* about the package and its members.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see javax.lang.model.util.Elements#getPackageOf
* @since 1.6
*/
public interface PackageElement extends Element, QualifiedNameable {
/**
* Returns the fully qualified name of this package.
* This is also known as the package's <i>canonical</i> name.
*
* @return the fully qualified name of this package, or an
* empty name if this is an unnamed package
* @jls 6.7 Fully Qualified Names and Canonical Names
*/
Name getQualifiedName();
/**
* Returns the simple name of this package. For an unnamed
* package, an empty name is returned.
*
* @return the simple name of this package or an empty name if
* this is an unnamed package
*/
@Override
Name getSimpleName();
/**
* Returns the {@linkplain NestingKind#TOP_LEVEL top-level}
* classes and interfaces within this package. Note that
* subpackages are <em>not</em> considered to be enclosed by a
* package.
*
* @return the top-level classes and interfaces within this
* package
*/
@Override
List<? extends Element> getEnclosedElements();
/**
* Returns {@code true} is this is an unnamed package and {@code
* false} otherwise.
*
* @return {@code true} is this is an unnamed package and {@code
* false} otherwise
* @jls 7.4.2 Unnamed Packages
*/
boolean isUnnamed();
/**
* Returns {@code null} since a package is not enclosed by another
* element.
*
* @return {@code null}
*/
@Override
Element getEnclosingElement();
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import java.util.List;
/**
* A mixin interface for an element that has type parameters.
*
* @author Joseph D. Darcy
* @since 1.7
*/
public interface Parameterizable extends Element {
/**
* Returns the formal type parameters of the type element in
* declaration order.
*
* @return the formal type parameters, or an empty list
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
/**
* A mixin interface for an element that has a qualified name.
*
* @author Joseph D. Darcy
* @since 1.7
*/
public interface QualifiedNameable extends Element {
/**
* Returns the fully qualified name of an element.
*
* @return the fully qualified name of an element
*/
Name getQualifiedName();
}

View File

@@ -0,0 +1,164 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
/**
* Represents a class or interface program element. Provides access
* to information about the type and its members. Note that an enum
* type is a kind of class and an annotation type is a kind of
* interface.
*
* <p> <a name="ELEM_VS_TYPE"></a>
* While a {@code TypeElement} represents a class or interface
* <i>element</i>, a {@link DeclaredType} represents a class
* or interface <i>type</i>, the latter being a use
* (or <i>invocation</i>) of the former.
* The distinction is most apparent with generic types,
* for which a single element can define a whole
* family of types. For example, the element
* {@code java.util.Set} corresponds to the parameterized types
* {@code java.util.Set<String>} and {@code java.util.Set<Number>}
* (and many others), and to the raw type {@code java.util.Set}.
*
* <p> Each method of this interface that returns a list of elements
* will return them in the order that is natural for the underlying
* source of program information. For example, if the underlying
* source of information is Java source code, then the elements will be
* returned in source code order.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see DeclaredType
* @since 1.6
*/
public interface TypeElement extends Element, Parameterizable, QualifiedNameable {
/**
* Returns the fields, methods, constructors, and member types
* that are directly declared in this class or interface.
*
* This includes any (implicit) default constructor and
* the implicit {@code values} and {@code valueOf} methods of an
* enum type.
*
* <p> Note that as a particular instance of the {@linkplain
* javax.lang.model.element general accuracy requirements} and the
* ordering behavior required of this interface, the list of
* enclosed elements will be returned in the natural order for the
* originating source of information about the type. For example,
* if the information about the type is originating from a source
* file, the elements will be returned in source code order.
* (However, in that case the the ordering of synthesized
* elements, such as a default constructor, is not specified.)
*
* @return the enclosed elements in proper order, or an empty list if none
*/
@Override
List<? extends Element> getEnclosedElements();
/**
* Returns the <i>nesting kind</i> of this type element.
*
* @return the nesting kind of this type element
*/
NestingKind getNestingKind();
/**
* Returns the fully qualified name of this type element.
* More precisely, it returns the <i>canonical</i> name.
* For local and anonymous classes, which do not have canonical names,
* an empty name is returned.
*
* <p>The name of a generic type does not include any reference
* to its formal type parameters.
* For example, the fully qualified name of the interface
* {@code java.util.Set<E>} is "{@code java.util.Set}".
* Nested types use "{@code .}" as a separator, as in
* "{@code java.util.Map.Entry}".
*
* @return the fully qualified name of this class or interface, or
* an empty name if none
*
* @see Elements#getBinaryName
* @jls 6.7 Fully Qualified Names and Canonical Names
*/
Name getQualifiedName();
/**
* Returns the simple name of this type element.
*
* For an anonymous class, an empty name is returned.
*
* @return the simple name of this class or interface,
* an empty name for an anonymous class
*
*/
@Override
Name getSimpleName();
/**
* Returns the direct superclass of this type element.
* If this type element represents an interface or the class
* {@code java.lang.Object}, then a {@link NoType}
* with kind {@link TypeKind#NONE NONE} is returned.
*
* @return the direct superclass, or a {@code NoType} if there is none
*/
TypeMirror getSuperclass();
/**
* Returns the interface types directly implemented by this class
* or extended by this interface.
*
* @return the interface types directly implemented by this class
* or extended by this interface, or an empty list if there are none
*/
List<? extends TypeMirror> getInterfaces();
/**
* Returns the formal type parameters of this type element
* in declaration order.
*
* @return the formal type parameters, or an empty list
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
/**
* Returns the package of a top-level type and returns the
* immediately lexically enclosing element for a {@linkplain
* NestingKind#isNested nested} type.
*
* @return the package of a top-level type, the immediately
* lexically enclosing element for a nested type
*/
@Override
Element getEnclosingElement();
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
/**
* Represents a formal type parameter of a generic class, interface, method,
* or constructor element.
* A type parameter declares a {@link TypeVariable}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see TypeVariable
* @since 1.6
*/
public interface TypeParameterElement extends Element {
/**
* Returns the generic class, interface, method, or constructor that is
* parameterized by this type parameter.
*
* @return the generic class, interface, method, or constructor that is
* parameterized by this type parameter
*/
Element getGenericElement();
/**
* Returns the bounds of this type parameter.
* These are the types given by the {@code extends} clause
* used to declare this type parameter.
* If no explicit {@code extends} clause was used,
* then {@code java.lang.Object} is considered to be the sole bound.
*
* @return the bounds of this type parameter, or an empty list if
* there are none
*/
List<? extends TypeMirror> getBounds();
/**
* Returns the {@linkplain TypeParameterElement#getGenericElement generic element} of this type parameter.
*
* @return the generic element of this type parameter
*/
@Override
Element getEnclosingElement();
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import javax.lang.model.UnknownEntityException;
/**
* Indicates that an unknown kind of annotation value was encountered.
* This can occur if the language evolves and new kinds of annotation
* values can be stored in an annotation. May be thrown by an
* {@linkplain AnnotationValueVisitor annotation value visitor} to
* indicate that the visitor was created for a prior version of the
* language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see AnnotationValueVisitor#visitUnknown
* @since 1.6
*/
public class UnknownAnnotationValueException extends UnknownEntityException {
private static final long serialVersionUID = 269L;
private transient AnnotationValue av;
private transient Object parameter;
/**
* Creates a new {@code UnknownAnnotationValueException}. The
* {@code p} parameter may be used to pass in an additional
* argument with information about the context in which the
* unknown annotation value was encountered; for example, the
* visit methods of {@link AnnotationValueVisitor} may pass in
* their additional parameter.
*
* @param av the unknown annotation value, may be {@code null}
* @param p an additional parameter, may be {@code null}
*/
public UnknownAnnotationValueException(AnnotationValue av, Object p) {
super("Unknown annotation value: " + av);
this.av = av;
this.parameter = p;
}
/**
* Returns the unknown annotation value.
* The value may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the unknown element, or {@code null} if unavailable
*/
public AnnotationValue getUnknownAnnotationValue() {
return av;
}
/**
* Returns the additional argument.
*
* @return the additional argument
*/
public Object getArgument() {
return parameter;
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import javax.lang.model.UnknownEntityException;
/**
* Indicates that an unknown kind of element was encountered. This
* can occur if the language evolves and new kinds of elements are
* added to the {@code Element} hierarchy. May be thrown by an
* {@linkplain ElementVisitor element visitor} to indicate that the
* visitor was created for a prior version of the language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @see ElementVisitor#visitUnknown
* @since 1.6
*/
public class UnknownElementException extends UnknownEntityException {
private static final long serialVersionUID = 269L;
private transient Element element;
private transient Object parameter;
/**
* Creates a new {@code UnknownElementException}. The {@code p}
* parameter may be used to pass in an additional argument with
* information about the context in which the unknown element was
* encountered; for example, the visit methods of {@link
* ElementVisitor} may pass in their additional parameter.
*
* @param e the unknown element, may be {@code null}
* @param p an additional parameter, may be {@code null}
*/
public UnknownElementException(Element e, Object p) {
super("Unknown element: " + e);
element = e;
this.parameter = p;
}
/**
* Returns the unknown element.
* The value may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the unknown element, or {@code null} if unavailable
*/
public Element getUnknownElement() {
return element;
}
/**
* Returns the additional argument.
*
* @return the additional argument
*/
public Object getArgument() {
return parameter;
}
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.element;
import javax.lang.model.util.Elements;
/**
* Represents a field, {@code enum} constant, method or constructor
* parameter, local variable, resource variable, or exception
* parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
public interface VariableElement extends Element {
/**
* Returns the value of this variable if this is a {@code final}
* field initialized to a compile-time constant. Returns {@code
* null} otherwise. The value will be of a primitive type or a
* {@code String}. If the value is of a primitive type, it is
* wrapped in the appropriate wrapper class (such as {@link
* Integer}).
*
* <p>Note that not all {@code final} fields will have
* constant values. In particular, {@code enum} constants are
* <em>not</em> considered to be compile-time constants. To have a
* constant value, a field's type must be either a primitive type
* or {@code String}.
*
* @return the value of this variable if this is a {@code final}
* field initialized to a compile-time constant, or {@code null}
* otherwise
*
* @see Elements#getConstantExpression(Object)
* @jls 15.28 Constant Expression
* @jls 4.12.4 final Variables
*/
Object getConstantValue();
/**
* Returns the simple name of this variable element.
*
* <p>For method and constructor parameters, the name of each
* parameter must be distinct from the names of all other
* parameters of the same executable. If the original source
* names are not available, an implementation may synthesize names
* subject to the distinctness requirement above.
*
* @return the simple name of this variable element
*/
@Override
Name getSimpleName();
/**
* Returns the enclosing element of this variable.
*
* The enclosing element of a method or constructor parameter is
* the executable declaring the parameter.
*
* @return the enclosing element of this variable
*/
@Override
Element getEnclosingElement();
}

View File

@@ -0,0 +1,101 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Interfaces used to model elements of the Java programming language.
*
* The term "element" in this package is used to refer to program
* elements, the declared entities that make up a program. Elements
* include classes, interfaces, methods, constructors, and fields.
* The interfaces in this package do not model the structure of a
* program inside a method body; for example there is no
* representation of a {@code for} loop or {@code try}-{@code finally}
* block. However, the interfaces can model some structures only
* appearing inside method bodies, such as local variables and
* anonymous classes.
*
* <p>When used in the context of annotation processing, an accurate
* model of the element being represented must be returned. As this
* is a language model, the source code provides the fiducial
* (reference) representation of the construct in question rather than
* a representation in an executable output like a class file.
* Executable output may serve as the basis for creating a modeling
* element. However, the process of translating source code to
* executable output may not permit recovering some aspects of the
* source code representation. For example, annotations with
* {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source}
* {@linkplain java.lang.annotation.Retention retention} cannot be
* recovered from class files and class files might not be able to
* provide source position information.
*
* Names of parameters may not be recoverable from class files.
*
* The {@linkplain javax.lang.model.element.Modifier modifiers} on an
* element may differ in some cases including:
*
* <ul>
* <li> {@code strictfp} on a class or interface
* <li> {@code final} on a parameter
* <li> {@code protected}, {@code private}, and {@code static} on classes and interfaces
* </ul>
*
* Additionally, synthetic constructs in a class file, such as
* accessor methods used in implementing nested classes and bridge
* methods used in implementing covariant returns, are translation
* artifacts outside of this model.
*
* <p>During annotation processing, operating on incomplete or
* erroneous programs is necessary; however, there are fewer
* guarantees about the nature of the resulting model. If the source
* code is not syntactically well-formed or has some other
* irrecoverable error that could not be removed by the generation of
* new types, a model may or may not be provided as a quality of
* implementation issue.
* If a program is syntactically valid but erroneous in some other
* fashion, any returned model must have no less information than if
* all the method bodies in the program were replaced by {@code "throw
* new RuntimeException();"}. If a program refers to a missing type XYZ,
* the returned model must contain no less information than if the
* declaration of type XYZ were assumed to be {@code "class XYZ {}"},
* {@code "interface XYZ {}"}, {@code "enum XYZ {}"}, or {@code
* "@interface XYZ {}"}. If a program refers to a missing type {@code
* XYZ<K1, ... ,Kn>}, the returned model must contain no less
* information than if the declaration of XYZ were assumed to be
* {@code "class XYZ<T1, ... ,Tn> {}"} or {@code "interface XYZ<T1,
* ... ,Tn> {}"}
*
* <p> Unless otherwise specified in a particular implementation, the
* collections returned by methods in this package should be expected
* to be unmodifiable by the caller and unsafe for concurrent access.
*
* <p> Unless otherwise specified, methods in this package will throw
* a {@code NullPointerException} if given a {@code null} argument.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
* @since 1.6
*/
package javax.lang.model.element;