Module java.base
Package java.lang.classfile.attributePREVIEW

# Interface SourceFileAttribute

All Superinterfaces:
  `AttributePREVIEW<SourceFileAttributePREVIEW>`, `ClassElementPREVIEW`, `ClassFileElementPREVIEW`, `WritableElementPREVIEW<SourceFileAttributePREVIEW>`

public sealed interface SourceFileAttribute extends AttributePREVIEW<SourceFileAttributePREVIEW>, ClassElementPREVIEW
`SourceFileAttribute` is a preview API of the Java platform.
Programs can only use `SourceFileAttribute` 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 `SourceFile` attribute 4.7.10, which can appear on classes. Delivered as a `ClassElement`PREVIEW when traversing a `ClassModel`PREVIEW.

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.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static SourceFileAttributePREVIEW`
  `of(Utf8EntryPREVIEW sourceFile)`
  Returns a source file attribute.
  `static SourceFileAttributePREVIEW`
  `of(String sourceFile)`
  Returns a source file attribute.
  `Utf8EntryPREVIEW`
  `sourceFile()`
  Returns the name of the source file from which this class was compiled.

  ### Methods declared in interface java.lang.classfile.AttributePREVIEW

  `attributeMapper, attributeName`

  ### Methods declared in interface java.lang.classfile.WritableElementPREVIEW

  `writeTo`

- ## Method Details

  - ### sourceFile

    Utf8EntryPREVIEW sourceFile()
    Returns the name of the source file from which this class was compiled.
    Returns:
      the name of the source file from which this class was compiled

  - ### of

    static SourceFileAttributePREVIEW of(String sourceFile)
    Returns a source file attribute.
    Parameters:
      `sourceFile` - the source file name
    Returns:
      a source file attribute

  - ### of

    static SourceFileAttributePREVIEW of(Utf8EntryPREVIEW sourceFile)
    Returns a source file attribute.
    Parameters:
      `sourceFile` - the source file name
    Returns:
      a source file attribute