APIdia Launch Partner
Top Description Methods
java.lang.classfile.attribute

public sealed Interface ModuleMainClassAttribute

extends Attribute<ModuleMainClassAttribute>, ClassElement
permits BoundModuleMainClassAttribute, UnboundModuleMainClassAttribute
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundModuleMainClassAttribute, jdk.internal.classfile.impl.UnboundAttribute.UnboundModuleMainClassAttribute
Imports
java.lang.classfile.Attribute, .AttributeMapper, .AttributeMapper.AttributeStability, .Attributes, .ClassElement, .ClassFile, .ClassModel, java.lang.classfile.constantpool.ClassEntry, java.lang.constant.ClassDesc, java.lang.module.ModuleDescriptor, jdk.internal.classfile.impl.BoundAttribute, .TemporaryConstantPool, .UnboundAttribute

Models the ModuleMainClass attribute (JVMS 4.7.27), which appears on classes that represent module descriptors to indicate the main class of the module.

This attribute only appears on classes, and does not permit multiple instances in a class. It has a data dependency on the constant pool.

The attribute was introduced in the Java SE Platform version 9, major version 53.

Since
24
Java Virtual Machine Specification
4.7.27 The ModuleMainClass Attribute
See Also
Attributes#moduleMainClass(), ModuleDescriptor#mainClass()

Method Summary

Modifier and TypeMethod and Description
public ClassEntry

Returns:

main class for this module
mainClass
()

Returns main class for this module.

public static ModuleMainClassAttribute

Returns:

a ModuleMainClass attribute
of
(ClassEntry
the main class
mainClass
)

Returns a ModuleMainClass attribute.

public static ModuleMainClassAttribute

Returns:

a ModuleMainClass attribute
of
(ClassDesc
the main class
mainClass
)

Returns a ModuleMainClass attribute.

Inherited from java.lang.classfile.Attribute:
attributeMapperattributeName

Method Detail

mainClassback to summary
public ClassEntry mainClass()

Returns main class for this module.

Returns:ClassEntry

main class for this module

ofback to summary
public static ModuleMainClassAttribute of(ClassEntry mainClass)

Returns a ModuleMainClass attribute.

Parameters
mainClass:ClassEntry

the main class

Returns:ModuleMainClassAttribute

a ModuleMainClass attribute

ofback to summary
public static ModuleMainClassAttribute of(ClassDesc mainClass)

Returns a ModuleMainClass attribute.

Parameters
mainClass:ClassDesc

the main class

Returns:ModuleMainClassAttribute

a ModuleMainClass attribute

Exceptions
IllegalArgumentException:
if mainClass represents a primitive type