Top Description Methods
java.lang.classfile.attribute

public sealed Interface ModuleMainClassAttribute

extends Attribute<ModuleMainClassAttribute>, ClassElement
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundModuleMainClassAttribute, jdk.internal.classfile.impl.UnboundAttribute.UnboundModuleMainClassAttribute
Annotations
@PreviewFeature
feature:CLASSFILE_API
Imports
java.lang.constant.ClassDesc, java.lang.classfile.Attribute, .ClassElement, java.lang.classfile.constantpool.ClassEntry, jdk.internal.classfile.impl.BoundAttribute, .TemporaryConstantPool, .UnboundAttribute, jdk.internal.javac.PreviewFeature

Preview

Second Preview of ClassFile API (JEP 466).

Programs can only use ModuleMainClassAttribute when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.

Models the ModuleMainClass attribute 4.7.27, which can appear on classes that represent module descriptors. Delivered as a java.lang.classfile.ClassElement when traversing the elements of a java.lang.classfile.ClassModel.

The attribute does not permit multiple instances in a given location. Subsequent occurrence of the attribute takes precedence during the attributed element build or transformation.

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

Since
22

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