3887 * nest; and {@code false} otherwise. 3888 * 3889 * @since 11 3890 */ 3891 public boolean isNestmateOf(Class<?> c) { 3892 // We could use Reflection.areNestmates(this, c) and ignore 3893 // any IllegalAccessError, but prefer to minimize exception 3894 // creation by using getNestHost() directly. 3895 return getNestHost() == c.getNestHost(); 3896 } 3897 3898 private native Class<?>[] getNestMembers0(); 3899 3900 /** 3901 * Returns an array containing {@code Class} objects representing all the 3902 * classes and interfaces that are declared in the 3903 * {@linkplain #getNestHost() nest host} of this class, as being members 3904 * of its nest. The nest host will always be the zeroeth element. 3905 * 3906 * <p>Each listed nest member must be validated by checking its own 3907 * declared {@linkplain #getNestHost() nest host}. Any exceptions that occur 3908 * as part of this process will be thrown. 3909 * 3910 * @return an array of all classes and interfaces in the same nest as 3911 * this class 3912 * 3913 * @throws LinkageError if there is any problem loading or validating 3914 * a nest member or its nest host 3915 * 3916 * @since 11 3917 */ 3918 public Class<?>[] getNestMembers() { 3919 if (isPrimitive() || isArray()) { 3920 return new Class<?>[] { this }; 3921 } 3922 return getNestMembers0(); 3923 } 3924 } | 3887 * nest; and {@code false} otherwise. 3888 * 3889 * @since 11 3890 */ 3891 public boolean isNestmateOf(Class<?> c) { 3892 // We could use Reflection.areNestmates(this, c) and ignore 3893 // any IllegalAccessError, but prefer to minimize exception 3894 // creation by using getNestHost() directly. 3895 return getNestHost() == c.getNestHost(); 3896 } 3897 3898 private native Class<?>[] getNestMembers0(); 3899 3900 /** 3901 * Returns an array containing {@code Class} objects representing all the 3902 * classes and interfaces that are declared in the 3903 * {@linkplain #getNestHost() nest host} of this class, as being members 3904 * of its nest. The nest host will always be the zeroeth element. 3905 * 3906 * <p>Each listed nest member must be validated by checking its own 3907 * declared nest host. Any exceptions that occur as part of this process 3908 * will be thrown. 3909 * 3910 * <p>The list of nest members in the classfile is permitted to 3911 * contain duplicates, or to explicitly include the nest host. It is not 3912 * required that an implementation of this method removes these duplicates. 3913 * 3914 * @implNote This implementation does not remove duplicate nest members if they 3915 * are present. 3916 * 3917 * @return an array of all classes and interfaces in the same nest as 3918 * this class 3919 * 3920 * @throws LinkageError if there is any problem loading or validating 3921 * a nest member or its nest host 3922 * 3923 * @since 11 3924 */ 3925 public Class<?>[] getNestMembers() { 3926 if (isPrimitive() || isArray()) { 3927 return new Class<?>[] { this }; 3928 } 3929 return getNestMembers0(); 3930 } 3931 } |