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

public sealed Interface SourceFileAttribute

extends Attribute<SourceFileAttribute>, ClassElement
permits BoundSourceFileAttribute, UnboundSourceFileAttribute
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundSourceFileAttribute, jdk.internal.classfile.impl.UnboundAttribute.UnboundSourceFileAttribute
Imports
java.lang.classfile.Attribute, .AttributeMapper, .AttributeMapper.AttributeStability, .Attributes, .ClassElement, .ClassFile, java.lang.classfile.constantpool.Utf8Entry, jdk.internal.classfile.impl.BoundAttribute, .TemporaryConstantPool, .UnboundAttribute

Models the SourceFile attribute (JVMS 4.7.10), which indicates the name of the source file from which this class file was compiled.

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 5.0, major version 49.

Since
24
Java Virtual Machine Specification
4.7.10 The SourceFile Attribute
See Also
Attributes#sourceFile()

Method Summary

Modifier and TypeMethod and Description
public static SourceFileAttribute

Returns:

a source file attribute
of
(String
the source file name
sourceFile
)

Returns a source file attribute.

public static SourceFileAttribute

Returns:

a source file attribute
of
(Utf8Entry
the source file name
sourceFile
)

Returns a source file attribute.

public Utf8Entry

Returns:

the name of the source file from which this class was compiled
sourceFile
()

Returns the name of the source file from which this class was compiled.

Inherited from java.lang.classfile.Attribute:
attributeMapperattributeName

Method Detail

ofback to summary
public static SourceFileAttribute of(String sourceFile)

Returns a source file attribute.

Parameters
sourceFile:String

the source file name

Returns:SourceFileAttribute

a source file attribute

ofback to summary
public static SourceFileAttribute of(Utf8Entry sourceFile)

Returns a source file attribute.

Parameters
sourceFile:Utf8Entry

the source file name

Returns:SourceFileAttribute

a source file attribute

sourceFileback to summary
public Utf8Entry sourceFile()

Returns the name of the source file from which this class was compiled.

Returns:Utf8Entry

the name of the source file from which this class was compiled