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 */
201 * that declares the executable represented by this object.
202 */
203 public abstract Class<?> getDeclaringClass();
204
205 /**
206 * Returns the name of the executable represented by this object.
207 */
208 public abstract String getName();
209
210 /**
211 * {@return the Java language {@linkplain Modifier modifiers} for
212 * the executable represented by this object}
213 * @see #accessFlags
214 */
215 public abstract int getModifiers();
216
217 /**
218 * {@return an unmodifiable set of the {@linkplain AccessFlag
219 * access flags} for the executable represented by this object,
220 * possibly empty}
221 *
222 * @see #getModifiers()
223 * @jvms 4.6 Methods
224 * @since 20
225 */
226 @Override
227 public Set<AccessFlag> accessFlags() {
228 return reflectionFactory.parseAccessFlags(getModifiers(),
229 AccessFlag.Location.METHOD,
230 getDeclaringClass());
231 }
232
233 /**
234 * Returns an array of {@code TypeVariable} objects that represent the
235 * type variables declared by the generic declaration represented by this
236 * {@code GenericDeclaration} object, in declaration order. Returns an
237 * array of length 0 if the underlying generic declaration declares no type
238 * variables.
239 *
240 * @return an array of {@code TypeVariable} objects that represent
241 * the type variables declared by this generic declaration
242 * @throws GenericSignatureFormatError if the generic
243 * signature of this generic declaration does not conform to
244 * the format specified in
245 * <cite>The Java Virtual Machine Specification</cite>
246 */
247 public abstract TypeVariable<?>[] getTypeParameters();
248
249 // returns shared array of parameter types - must never give it out
250 // 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 */
202 * that declares the executable represented by this object.
203 */
204 public abstract Class<?> getDeclaringClass();
205
206 /**
207 * Returns the name of the executable represented by this object.
208 */
209 public abstract String getName();
210
211 /**
212 * {@return the Java language {@linkplain Modifier modifiers} for
213 * the executable represented by this object}
214 * @see #accessFlags
215 */
216 public abstract int getModifiers();
217
218 /**
219 * {@return an unmodifiable set of the {@linkplain AccessFlag
220 * access flags} for the executable represented by this object,
221 * possibly empty}
222 * The {@code AccessFlags} may depend on the class file format version of the class.
223 *
224 * @see #getModifiers()
225 * @jvms 4.6 Methods
226 * @since 20
227 */
228 @Override
229 public Set<AccessFlag> accessFlags() {
230 return AccessFlagSet.ofValidated(AccessFlagSet.METHOD_FLAGS, getModifiers());
231 }
232
233 /**
234 * Returns an array of {@code TypeVariable} objects that represent the
235 * type variables declared by the generic declaration represented by this
236 * {@code GenericDeclaration} object, in declaration order. Returns an
237 * array of length 0 if the underlying generic declaration declares no type
238 * variables.
239 *
240 * @return an array of {@code TypeVariable} objects that represent
241 * the type variables declared by this generic declaration
242 * @throws GenericSignatureFormatError if the generic
243 * signature of this generic declaration does not conform to
244 * the format specified in
245 * <cite>The Java Virtual Machine Specification</cite>
246 */
247 public abstract TypeVariable<?>[] getTypeParameters();
248
249 // returns shared array of parameter types - must never give it out
250 // to the untrusted code...
|