358 * name is {@code name}. Therefore, this method cannot be used to
359 * obtain any of the {@code Class} objects representing primitive
360 * types or void.
361 *
362 * <p> If {@code name} denotes an array class, the component type of
363 * the array class is loaded but not initialized.
364 *
365 * <p> For example, in an instance method the expression:
366 *
367 * <blockquote>
368 * {@code Class.forName("Foo")}
369 * </blockquote>
370 *
371 * is equivalent to:
372 *
373 * <blockquote>
374 * {@code Class.forName("Foo", true, this.getClass().getClassLoader())}
375 * </blockquote>
376 *
377 * Note that this method throws errors related to loading, linking or
378 * initializing as specified in Sections 12.2, 12.3 and 12.4 of <em>The
379 * Java Language Specification</em>.
380 * Note that this method does not check whether the requested class
381 * is accessible to its caller.
382 *
383 * @param name fully qualified name of the desired class
384 * @param initialize if {@code true} the class will be initialized (which implies linking).
385 * See Section 12.4 of <em>The Java Language Specification</em>.
386 * @param loader class loader from which the class must be loaded
387 * @return class object representing the desired class
388 *
389 * @throws LinkageError if the linkage fails
390 * @throws ExceptionInInitializerError if the initialization provoked
391 * by this method fails
392 * @throws ClassNotFoundException if the class cannot be located by
393 * the specified class loader
394 * @throws SecurityException
395 * if a security manager is present, and the {@code loader} is
396 * {@code null}, and the caller's class loader is not
397 * {@code null}, and the caller does not have the
398 * {@link RuntimePermission}{@code ("getClassLoader")}
399 *
400 * @see java.lang.Class#forName(String)
401 * @see java.lang.ClassLoader
402 *
403 * @jls 12.2 Loading of Classes and Interfaces
404 * @jls 12.3 Linking of Classes and Interfaces
405 * @jls 12.4 Initialization of Classes and Interfaces
643 */
644 @HotSpotIntrinsicCandidate
645 public native boolean isInstance(Object obj);
646
647
648 /**
649 * Determines if the class or interface represented by this
650 * {@code Class} object is either the same as, or is a superclass or
651 * superinterface of, the class or interface represented by the specified
652 * {@code Class} parameter. It returns {@code true} if so;
653 * otherwise it returns {@code false}. If this {@code Class}
654 * object represents a primitive type, this method returns
655 * {@code true} if the specified {@code Class} parameter is
656 * exactly this {@code Class} object; otherwise it returns
657 * {@code false}.
658 *
659 * <p> Specifically, this method tests whether the type represented by the
660 * specified {@code Class} parameter can be converted to the type
661 * represented by this {@code Class} object via an identity conversion
662 * or via a widening reference conversion. See <em>The Java Language
663 * Specification</em>, sections 5.1.1 and 5.1.4 , for details.
664 *
665 * @param cls the {@code Class} object to be checked
666 * @return the {@code boolean} value indicating whether objects of the
667 * type {@code cls} can be assigned to objects of this class
668 * @throws NullPointerException if the specified Class parameter is
669 * null.
670 * @since 1.1
671 */
672 @HotSpotIntrinsicCandidate
673 public native boolean isAssignableFrom(Class<?> cls);
674
675
676 /**
677 * Determines if the specified {@code Class} object represents an
678 * interface type.
679 *
680 * @return {@code true} if this object represents an interface;
681 * {@code false} otherwise.
682 */
683 @HotSpotIntrinsicCandidate
2382 public Method[] getDeclaredMethods() throws SecurityException {
2383 SecurityManager sm = System.getSecurityManager();
2384 if (sm != null) {
2385 checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
2386 }
2387 return copyMethods(privateGetDeclaredMethods(false));
2388 }
2389
2390
2391 /**
2392 * Returns an array of {@code Constructor} objects reflecting all the
2393 * constructors declared by the class represented by this
2394 * {@code Class} object. These are public, protected, default
2395 * (package) access, and private constructors. The elements in the array
2396 * returned are not sorted and are not in any particular order. If the
2397 * class has a default constructor, it is included in the returned array.
2398 * This method returns an array of length 0 if this {@code Class}
2399 * object represents an interface, a primitive type, an array class, or
2400 * void.
2401 *
2402 * <p> See <em>The Java Language Specification</em>, section 8.2.
2403 *
2404 * @return the array of {@code Constructor} objects representing all the
2405 * declared constructors of this class
2406 * @throws SecurityException
2407 * If a security manager, <i>s</i>, is present and any of the
2408 * following conditions is met:
2409 *
2410 * <ul>
2411 *
2412 * <li> the caller's class loader is not the same as the
2413 * class loader of this class and invocation of
2414 * {@link SecurityManager#checkPermission
2415 * s.checkPermission} method with
2416 * {@code RuntimePermission("accessDeclaredMembers")}
2417 * denies access to the declared constructors within this class
2418 *
2419 * <li> the caller's class loader is not the same as or an
2420 * ancestor of the class loader for the current class and
2421 * invocation of {@link SecurityManager#checkPackageAccess
2422 * s.checkPackageAccess()} denies access to the package
|
358 * name is {@code name}. Therefore, this method cannot be used to
359 * obtain any of the {@code Class} objects representing primitive
360 * types or void.
361 *
362 * <p> If {@code name} denotes an array class, the component type of
363 * the array class is loaded but not initialized.
364 *
365 * <p> For example, in an instance method the expression:
366 *
367 * <blockquote>
368 * {@code Class.forName("Foo")}
369 * </blockquote>
370 *
371 * is equivalent to:
372 *
373 * <blockquote>
374 * {@code Class.forName("Foo", true, this.getClass().getClassLoader())}
375 * </blockquote>
376 *
377 * Note that this method throws errors related to loading, linking or
378 * initializing as specified in Sections {@jls 12.2}, {@jls 12.3}, and {@jls 12.4} of <em>The
379 * Java Language Specification</em>.
380 * Note that this method does not check whether the requested class
381 * is accessible to its caller.
382 *
383 * @param name fully qualified name of the desired class
384 * @param initialize if {@code true} the class will be initialized (which implies linking).
385 * See Section {@jls 12.4} of <em>The Java Language Specification</em>.
386 * @param loader class loader from which the class must be loaded
387 * @return class object representing the desired class
388 *
389 * @throws LinkageError if the linkage fails
390 * @throws ExceptionInInitializerError if the initialization provoked
391 * by this method fails
392 * @throws ClassNotFoundException if the class cannot be located by
393 * the specified class loader
394 * @throws SecurityException
395 * if a security manager is present, and the {@code loader} is
396 * {@code null}, and the caller's class loader is not
397 * {@code null}, and the caller does not have the
398 * {@link RuntimePermission}{@code ("getClassLoader")}
399 *
400 * @see java.lang.Class#forName(String)
401 * @see java.lang.ClassLoader
402 *
403 * @jls 12.2 Loading of Classes and Interfaces
404 * @jls 12.3 Linking of Classes and Interfaces
405 * @jls 12.4 Initialization of Classes and Interfaces
643 */
644 @HotSpotIntrinsicCandidate
645 public native boolean isInstance(Object obj);
646
647
648 /**
649 * Determines if the class or interface represented by this
650 * {@code Class} object is either the same as, or is a superclass or
651 * superinterface of, the class or interface represented by the specified
652 * {@code Class} parameter. It returns {@code true} if so;
653 * otherwise it returns {@code false}. If this {@code Class}
654 * object represents a primitive type, this method returns
655 * {@code true} if the specified {@code Class} parameter is
656 * exactly this {@code Class} object; otherwise it returns
657 * {@code false}.
658 *
659 * <p> Specifically, this method tests whether the type represented by the
660 * specified {@code Class} parameter can be converted to the type
661 * represented by this {@code Class} object via an identity conversion
662 * or via a widening reference conversion. See <em>The Java Language
663 * Specification</em>, sections {@jls 5.1.1} and {@jls 5.1.4} , for details.
664 *
665 * @param cls the {@code Class} object to be checked
666 * @return the {@code boolean} value indicating whether objects of the
667 * type {@code cls} can be assigned to objects of this class
668 * @throws NullPointerException if the specified Class parameter is
669 * null.
670 * @since 1.1
671 */
672 @HotSpotIntrinsicCandidate
673 public native boolean isAssignableFrom(Class<?> cls);
674
675
676 /**
677 * Determines if the specified {@code Class} object represents an
678 * interface type.
679 *
680 * @return {@code true} if this object represents an interface;
681 * {@code false} otherwise.
682 */
683 @HotSpotIntrinsicCandidate
2382 public Method[] getDeclaredMethods() throws SecurityException {
2383 SecurityManager sm = System.getSecurityManager();
2384 if (sm != null) {
2385 checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
2386 }
2387 return copyMethods(privateGetDeclaredMethods(false));
2388 }
2389
2390
2391 /**
2392 * Returns an array of {@code Constructor} objects reflecting all the
2393 * constructors declared by the class represented by this
2394 * {@code Class} object. These are public, protected, default
2395 * (package) access, and private constructors. The elements in the array
2396 * returned are not sorted and are not in any particular order. If the
2397 * class has a default constructor, it is included in the returned array.
2398 * This method returns an array of length 0 if this {@code Class}
2399 * object represents an interface, a primitive type, an array class, or
2400 * void.
2401 *
2402 * <p> See <em>The Java Language Specification</em>, section {@jls 8.2}.
2403 *
2404 * @return the array of {@code Constructor} objects representing all the
2405 * declared constructors of this class
2406 * @throws SecurityException
2407 * If a security manager, <i>s</i>, is present and any of the
2408 * following conditions is met:
2409 *
2410 * <ul>
2411 *
2412 * <li> the caller's class loader is not the same as the
2413 * class loader of this class and invocation of
2414 * {@link SecurityManager#checkPermission
2415 * s.checkPermission} method with
2416 * {@code RuntimePermission("accessDeclaredMembers")}
2417 * denies access to the declared constructors within this class
2418 *
2419 * <li> the caller's class loader is not the same as or an
2420 * ancestor of the class loader for the current class and
2421 * invocation of {@link SecurityManager#checkPackageAccess
2422 * s.checkPackageAccess()} denies access to the package
|