3893 *
3894 * @apiNote A {@code class} file of version 55.0 or greater may record the
3895 * host of the nest to which it belongs by using the {@code NestHost}
3896 * attribute (JVMS 4.7.28). Alternatively, a {@code class} file of
3897 * version 55.0 or greater may act as a nest host by enumerating the nest's
3898 * other members with the
3899 * {@code NestMembers} attribute (JVMS 4.7.29).
3900 * A {@code class} file of version 54.0 or lower does not use these
3901 * attributes.
3902 *
3903 * @return the nest host of this class or interface
3904 *
3905 * @throws SecurityException
3906 * If the returned class is not the current class, and
3907 * if a security manager, <i>s</i>, is present and the caller's
3908 * class loader is not the same as or an ancestor of the class
3909 * loader for the returned class and invocation of {@link
3910 * SecurityManager#checkPackageAccess s.checkPackageAccess()}
3911 * denies access to the package of the returned class
3912 * @since 11
3913 * @jvms 4.7.28 and 4.7.29 NestHost and NestMembers attributes
3914 * @jvms 5.4.4 Access Control
3915 */
3916 @CallerSensitive
3917 public Class<?> getNestHost() {
3918 if (isPrimitive() || isArray()) {
3919 return this;
3920 }
3921 Class<?> host;
3922 try {
3923 host = getNestHost0();
3924 } catch (LinkageError e) {
3925 // if we couldn't load our nest-host then we
3926 // act as-if we have no nest-host attribute
3927 return this;
3928 }
3929 // if null then nest membership validation failed, so we
3930 // act as-if we have no nest-host attribute
3931 if (host == null || host == this) {
3932 return this;
3933 }
|
3893 *
3894 * @apiNote A {@code class} file of version 55.0 or greater may record the
3895 * host of the nest to which it belongs by using the {@code NestHost}
3896 * attribute (JVMS 4.7.28). Alternatively, a {@code class} file of
3897 * version 55.0 or greater may act as a nest host by enumerating the nest's
3898 * other members with the
3899 * {@code NestMembers} attribute (JVMS 4.7.29).
3900 * A {@code class} file of version 54.0 or lower does not use these
3901 * attributes.
3902 *
3903 * @return the nest host of this class or interface
3904 *
3905 * @throws SecurityException
3906 * If the returned class is not the current class, and
3907 * if a security manager, <i>s</i>, is present and the caller's
3908 * class loader is not the same as or an ancestor of the class
3909 * loader for the returned class and invocation of {@link
3910 * SecurityManager#checkPackageAccess s.checkPackageAccess()}
3911 * denies access to the package of the returned class
3912 * @since 11
3913 * @jvms 4.7.28 The {@code NestHost} Attribute
3914 * @jvms 4.7.29 The {@code NestMembers} Attribute
3915 * @jvms 5.4.4 Access Control
3916 */
3917 @CallerSensitive
3918 public Class<?> getNestHost() {
3919 if (isPrimitive() || isArray()) {
3920 return this;
3921 }
3922 Class<?> host;
3923 try {
3924 host = getNestHost0();
3925 } catch (LinkageError e) {
3926 // if we couldn't load our nest-host then we
3927 // act as-if we have no nest-host attribute
3928 return this;
3929 }
3930 // if null then nest membership validation failed, so we
3931 // act as-if we have no nest-host attribute
3932 if (host == null || host == this) {
3933 return this;
3934 }
|