Attribute<SourceFileAttribute>, ClassElement, ClassFileElementpublic sealed interface SourceFileAttribute extends Attribute<SourceFileAttribute>, ClassElement
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.
SourceFile Attribute| Modifier and Type | Method | Description |
|---|---|---|
static SourceFileAttribute |
of |
Returns a source file attribute. |
static SourceFileAttribute |
of |
Returns a source file attribute. |
Utf8Entry |
sourceFile() |
Returns the name of the source file from which this class was compiled. |
attributeMapper, attributeName
Utf8Entry sourceFile()
static SourceFileAttribute of(String sourceFile)
sourceFile - the source file namestatic SourceFileAttribute of(Utf8Entry sourceFile)
sourceFile - the source file name
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/classfile/attribute/SourceFileAttribute.html