< prev index next >

src/java.base/share/classes/java/lang/reflect/Executable.java

Print this page

 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 java.lang.reflect;
 27 
 28 import java.lang.annotation.Annotation;
 29 import java.util.Arrays;
 30 import java.util.Map;
 31 import java.util.Set;
 32 import java.util.Objects;
 33 import java.util.StringJoiner;
 34 import java.util.stream.Collectors;
 35 
 36 import jdk.internal.access.SharedSecrets;

 37 import jdk.internal.vm.annotation.Stable;
 38 import sun.reflect.annotation.AnnotationParser;
 39 import sun.reflect.annotation.AnnotationSupport;
 40 import sun.reflect.annotation.TypeAnnotationParser;
 41 import sun.reflect.annotation.TypeAnnotation;
 42 import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
 43 import sun.reflect.generics.repository.ConstructorRepository;
 44 
 45 /**
 46  * A shared superclass for the common functionality of {@link Method}
 47  * and {@link Constructor}.
 48  *
 49  * @sealedGraph
 50  * @since 1.8
 51  */
 52 public abstract sealed class Executable extends AccessibleObject
 53     implements Member, GenericDeclaration permits Constructor, Method {
 54     /*
 55      * Only grant package-visibility to the constructor.
 56      */

185      * that declares the executable represented by this object.
186      */
187     public abstract Class<?> getDeclaringClass();
188 
189     /**
190      * Returns the name of the executable represented by this object.
191      */
192     public abstract String getName();
193 
194     /**
195      * {@return the Java language {@linkplain Modifier modifiers} for
196      * the executable represented by this object}
197      * @see #accessFlags
198      */
199     public abstract int getModifiers();
200 
201     /**
202      * {@return an unmodifiable set of the {@linkplain AccessFlag
203      * access flags} for the executable represented by this object,
204      * possibly empty}

205      *
206      * @see #getModifiers()
207      * @jvms 4.6 Methods
208      * @since 20
209      */
210     @Override
211     public Set<AccessFlag> accessFlags() {
212         return reflectionFactory.parseAccessFlags(getModifiers(),
213                                                   AccessFlag.Location.METHOD,
214                                                   getDeclaringClass());
215     }
216 
217     /**
218      * Returns an array of {@code TypeVariable} objects that represent the
219      * type variables declared by the generic declaration represented by this
220      * {@code GenericDeclaration} object, in declaration order.  Returns an
221      * array of length 0 if the underlying generic declaration declares no type
222      * variables.
223      *
224      * @return an array of {@code TypeVariable} objects that represent
225      *     the type variables declared by this generic declaration
226      * @throws GenericSignatureFormatError if the generic
227      *     signature of this generic declaration does not conform to
228      *     the format specified in
229      *     <cite>The Java Virtual Machine Specification</cite>
230      */
231     public abstract TypeVariable<?>[] getTypeParameters();
232 
233     // returns shared array of parameter types - must never give it out
234     // to the untrusted code...

 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 java.lang.reflect;
 27 
 28 import java.lang.annotation.Annotation;
 29 import java.util.Arrays;
 30 import java.util.Map;
 31 import java.util.Set;
 32 import java.util.Objects;
 33 import java.util.StringJoiner;
 34 import java.util.stream.Collectors;
 35 
 36 import jdk.internal.access.SharedSecrets;
 37 import jdk.internal.reflect.AccessFlagSet;
 38 import jdk.internal.vm.annotation.Stable;
 39 import sun.reflect.annotation.AnnotationParser;
 40 import sun.reflect.annotation.AnnotationSupport;
 41 import sun.reflect.annotation.TypeAnnotationParser;
 42 import sun.reflect.annotation.TypeAnnotation;
 43 import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
 44 import sun.reflect.generics.repository.ConstructorRepository;
 45 
 46 /**
 47  * A shared superclass for the common functionality of {@link Method}
 48  * and {@link Constructor}.
 49  *
 50  * @sealedGraph
 51  * @since 1.8
 52  */
 53 public abstract sealed class Executable extends AccessibleObject
 54     implements Member, GenericDeclaration permits Constructor, Method {
 55     /*
 56      * Only grant package-visibility to the constructor.
 57      */

186      * that declares the executable represented by this object.
187      */
188     public abstract Class<?> getDeclaringClass();
189 
190     /**
191      * Returns the name of the executable represented by this object.
192      */
193     public abstract String getName();
194 
195     /**
196      * {@return the Java language {@linkplain Modifier modifiers} for
197      * the executable represented by this object}
198      * @see #accessFlags
199      */
200     public abstract int getModifiers();
201 
202     /**
203      * {@return an unmodifiable set of the {@linkplain AccessFlag
204      * access flags} for the executable represented by this object,
205      * possibly empty}
206      * The {@code AccessFlags} may depend on the class file format version of the class.
207      *
208      * @see #getModifiers()
209      * @jvms 4.6 Methods
210      * @since 20
211      */
212     @Override
213     public Set<AccessFlag> accessFlags() {
214         return AccessFlagSet.ofValidated(AccessFlagSet.METHOD_FLAGS, getModifiers());


215     }
216 
217     /**
218      * Returns an array of {@code TypeVariable} objects that represent the
219      * type variables declared by the generic declaration represented by this
220      * {@code GenericDeclaration} object, in declaration order.  Returns an
221      * array of length 0 if the underlying generic declaration declares no type
222      * variables.
223      *
224      * @return an array of {@code TypeVariable} objects that represent
225      *     the type variables declared by this generic declaration
226      * @throws GenericSignatureFormatError if the generic
227      *     signature of this generic declaration does not conform to
228      *     the format specified in
229      *     <cite>The Java Virtual Machine Specification</cite>
230      */
231     public abstract TypeVariable<?>[] getTypeParameters();
232 
233     // returns shared array of parameter types - must never give it out
234     // to the untrusted code...
< prev index next >