< prev index next >

src/java.base/share/classes/java/lang/classfile/attribute/InnerClassInfo.java

Print this page

 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 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 package java.lang.classfile.attribute;
 26 
 27 import java.lang.classfile.constantpool.ClassEntry;
 28 import java.lang.classfile.constantpool.Utf8Entry;
 29 import java.lang.constant.ClassDesc;
 30 import java.lang.reflect.AccessFlag;

 31 import java.util.Optional;
 32 import java.util.Set;
 33 
 34 import jdk.internal.classfile.impl.TemporaryConstantPool;
 35 import jdk.internal.classfile.impl.UnboundAttribute;
 36 import jdk.internal.classfile.impl.Util;
 37 
 38 /**
 39  * Models a single entry in the {@link InnerClassesAttribute}.
 40  *
 41  * @see InnerClassesAttribute#classes()
 42  * @jvms 4.7.6 The {@code InnerClasses} Attribute
 43  * @since 24
 44  */
 45 public sealed interface InnerClassInfo
 46         permits UnboundAttribute.UnboundInnerClassInfo {
 47 
 48     /**
 49      * {@return the nested class described by this entry}
 50      */

 67     Optional<Utf8Entry> innerName();
 68 
 69     /**
 70      * {@return a bit mask of flags denoting access permissions and properties
 71      * of the inner class}  It is a {@link java.lang.classfile##u2 u2} value.
 72      *
 73      * @see Class#getModifiers()
 74      * @see AccessFlag.Location#INNER_CLASS
 75      */
 76     int flagsMask();
 77 
 78     /**
 79      * {@return a set of flag enums denoting access permissions and properties
 80      * of the nested class}
 81      *
 82      * @throws IllegalArgumentException if the flags mask has any undefined bit set
 83      * @see Class#accessFlags()
 84      * @see AccessFlag.Location#INNER_CLASS
 85      */
 86     default Set<AccessFlag> flags() {
 87         return AccessFlag.maskToAccessFlags(flagsMask(), AccessFlag.Location.INNER_CLASS);
 88     }
 89 
 90     /**
 91      * {@return whether a specific access flag is set}
 92      *
 93      * @param flag the access flag
 94      * @see AccessFlag.Location#INNER_CLASS
 95      */
 96     default boolean has(AccessFlag flag) {
 97         return Util.has(AccessFlag.Location.INNER_CLASS, flagsMask(), flag);
 98     }
 99 
100     /**
101      * {@return a nested class description}
102      * @param innerClass the nested class being described
103      * @param outerClass the class that has the nested class as a member, if it exists
104      * @param innerName the simple name of the nested class, if it is not anonymous
105      * @param flags the inner class access flags
106      * @throws IllegalArgumentException if {@code flags} is not {@link
107      *         java.lang.classfile##u2 u2}

 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 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 package java.lang.classfile.attribute;
 26 
 27 import java.lang.classfile.constantpool.ClassEntry;
 28 import java.lang.classfile.constantpool.Utf8Entry;
 29 import java.lang.constant.ClassDesc;
 30 import java.lang.reflect.AccessFlag;
 31 import java.lang.reflect.ClassFileFormatVersion;
 32 import java.util.Optional;
 33 import java.util.Set;
 34 
 35 import jdk.internal.classfile.impl.TemporaryConstantPool;
 36 import jdk.internal.classfile.impl.UnboundAttribute;
 37 import jdk.internal.classfile.impl.Util;
 38 
 39 /**
 40  * Models a single entry in the {@link InnerClassesAttribute}.
 41  *
 42  * @see InnerClassesAttribute#classes()
 43  * @jvms 4.7.6 The {@code InnerClasses} Attribute
 44  * @since 24
 45  */
 46 public sealed interface InnerClassInfo
 47         permits UnboundAttribute.UnboundInnerClassInfo {
 48 
 49     /**
 50      * {@return the nested class described by this entry}
 51      */

 68     Optional<Utf8Entry> innerName();
 69 
 70     /**
 71      * {@return a bit mask of flags denoting access permissions and properties
 72      * of the inner class}  It is a {@link java.lang.classfile##u2 u2} value.
 73      *
 74      * @see Class#getModifiers()
 75      * @see AccessFlag.Location#INNER_CLASS
 76      */
 77     int flagsMask();
 78 
 79     /**
 80      * {@return a set of flag enums denoting access permissions and properties
 81      * of the nested class}
 82      *
 83      * @throws IllegalArgumentException if the flags mask has any undefined bit set
 84      * @see Class#accessFlags()
 85      * @see AccessFlag.Location#INNER_CLASS
 86      */
 87     default Set<AccessFlag> flags() {
 88         return AccessFlag.maskToAccessFlags(flagsMask(), AccessFlag.Location.INNER_CLASS, ClassFileFormatVersion.CURRENT_PREVIEW_FEATURES);
 89     }
 90 
 91     /**
 92      * {@return whether a specific access flag is set}
 93      *
 94      * @param flag the access flag
 95      * @see AccessFlag.Location#INNER_CLASS
 96      */
 97     default boolean has(AccessFlag flag) {
 98         return Util.has(AccessFlag.Location.INNER_CLASS, flagsMask(), flag);
 99     }
100 
101     /**
102      * {@return a nested class description}
103      * @param innerClass the nested class being described
104      * @param outerClass the class that has the nested class as a member, if it exists
105      * @param innerName the simple name of the nested class, if it is not anonymous
106      * @param flags the inner class access flags
107      * @throws IllegalArgumentException if {@code flags} is not {@link
108      *         java.lang.classfile##u2 u2}
< prev index next >