1 /*
  2  * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 
 26 package javax.lang.model.element;
 27 
 28 import java.util.List;
 29 import javax.lang.model.type.*;
 30 
 31 /**
 32  * Represents a method, constructor, or initializer (static or
 33  * instance) of a class or interface, including annotation interface
 34  * elements.
 35  * Annotation interface elements are methods restricted to have no
 36  * formal parameters, no type parameters, and no {@code throws}
 37  * clause, among other restrictions; see JLS {@jls 9.6.1} for details
 38  *
 39  * @see ExecutableType
 40  * @since 1.6
 41  */
 42 public interface ExecutableElement extends Element, Parameterizable {
 43     /**
 44      * {@return the {@linkplain ExecutableType executable type} defined
 45      * by this executable element}
 46      *
 47      * @see ExecutableType
 48      */
 49     @Override
 50     TypeMirror asType();
 51 
 52     /**
 53      * Returns the formal type parameters of this executable
 54      * in declaration order.
 55      *
 56      * @return the formal type parameters, or an empty list
 57      * if there are none
 58      */
 59     List<? extends TypeParameterElement> getTypeParameters();
 60 
 61     /**
 62      * {@return the return type of this executable}
 63      * Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
 64      * if this executable is not a method, or is a method that does not
 65      * return a value.
 66      */
 67     TypeMirror getReturnType();
 68 
 69     /**
 70      * Returns the formal parameters of this executable.
 71      * They are returned in declaration order.
 72      *
 73      * @return the formal parameters,
 74      * or an empty list if there are none
 75      */
 76     List<? extends VariableElement> getParameters();
 77 
 78     /**
 79      * Returns the receiver type of this executable,
 80      * or {@link javax.lang.model.type.NoType NoType} with
 81      * kind {@link javax.lang.model.type.TypeKind#NONE NONE}
 82      * if the executable has no receiver type.
 83      *
 84      * An executable which is an instance method, or a constructor of an
 85      * inner class, has a receiver type derived from the {@linkplain
 86      * #getEnclosingElement declaring type}.
 87      *
 88      * An executable which is a static method, or a constructor of a
 89      * non-inner class, or an initializer (static or instance), has no
 90      * receiver type.
 91      *
 92      * @return the receiver type of this executable
 93      * @since 1.8
 94      *
 95      * @jls 8.4 Method Declarations
 96      * @jls 8.4.1 Formal Parameters
 97      * @jls 8.8 Constructor Declarations
 98      */
 99     TypeMirror getReceiverType();
100 
101     /**
102      * {@return {@code true} if this method or constructor accepts a variable
103      * number of arguments and returns {@code false} otherwise}
104      */
105     boolean isVarArgs();
106 
107     /**
108      * {@return {@code true} if this method is a default method and
109      * returns {@code false} otherwise}
110      * @since 1.8
111      */
112     boolean isDefault();
113 
114     /**
115      * Returns the exceptions and other throwables listed in this
116      * method or constructor's {@code throws} clause in declaration
117      * order.
118      *
119      * @return the exceptions and other throwables listed in the
120      * {@code throws} clause, or an empty list if there are none
121      */
122     List<? extends TypeMirror> getThrownTypes();
123 
124     /**
125      * Returns the default value if this executable is an annotation
126      * interface element.  Returns {@code null} if this method is not
127      * an annotation interface element, or if it is an annotation
128      * interface element with no default value.
129      *
130      * @return the default value, or {@code null} if none
131      */
132     AnnotationValue getDefaultValue();
133 
134     /**
135      * {@return the class or interface defining the executable}
136      */
137     @Override
138     Element getEnclosingElement();
139 
140     /**
141      * {@return the simple name of a constructor, method, or
142      * initializer}  For a constructor, the name {@code "<init>"} is
143      * returned, for a static initializer, the name {@code "<clinit>"}
144      * is returned, and for an anonymous class or instance
145      * initializer, an {@linkplain Name##empty_name empty name} is


146      * returned.
147      */
148     @Override
149     Name getSimpleName();
150 }
--- EOF ---