ClassSignature (Java SE 26 & JDK 26)
Description: declaration: module: java.base, package: java.lang.classfile, interface: ClassSignature
Keywords: java.lang.classfile.ClassSignature interface

# Interface ClassSignature

public sealed interface ClassSignature
Models the generic signature of a class or interface, as defined by JVMS 4.7.9.1.

See Java Language Specification:
  8.1 Class Declarations
  9.1 Interface Declarations
See Java Virtual Machine Specification:
  4.7.9.1 Signatures
Since:
  24
See Also:
  - `Class`
  - `SignatureAttribute`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ClassSignature`
  `of(Signature.ClassTypeSig superclassSignature, Signature.ClassTypeSig... superinterfaceSignatures)`
  Returns a class signature with no type parameter declaration.
  `static ClassSignature`
  `of(List<Signature.TypeParam> typeParameters, Signature.ClassTypeSig superclassSignature, Signature.ClassTypeSig... superinterfaceSignatures)`
  Returns a class signature.
  `static ClassSignature`
  `parseFrom(String classSignature)`
  Parses a raw class signature string into a Signature.
  `String`
  `signatureString()`
  Returns the raw signature string.
  `Signature.ClassTypeSig`
  `superclassSignature()`
  Returns the instantiation of the superclass in this signature.
  `List<Signature.ClassTypeSig>`
  `superinterfaceSignatures()`
  Returns the instantiation of the interfaces in this signature, may be empty.
  `List<Signature.TypeParam>`
  `typeParameters()`
  Returns the type parameters of this class or interface, may be empty.

- ## Method Details

  - ### typeParameters

    List<Signature.TypeParam> typeParameters()
    Returns the type parameters of this class or interface, may be empty.
    Returns:
      the type parameters of this class or interface, may be empty
    See Java Language Specification:
      8.1.2 Generic Classes and Type Parameters
      9.1.2 Generic Interfaces and Type Parameters
    See Also:
      - `Class.getTypeParameters()`

  - ### superclassSignature

    Signature.ClassTypeSig superclassSignature()
    Returns the instantiation of the superclass in this signature. Interfaces return a signature representing the `Object` class.
    Returns:
      the instantiation of the superclass in this signature
    See Java Language Specification:
      8.1.4 Superclasses and Subclasses
    See Also:
      - `Class.getGenericSuperclass()`

  - ### superinterfaceSignatures

    List<Signature.ClassTypeSig> superinterfaceSignatures()
    Returns the instantiation of the interfaces in this signature, may be empty.
    Returns:
      the instantiation of the interfaces in this signature, may be empty
    See Java Language Specification:
      8.1.5 Superinterfaces
      9.1.3 Superinterfaces and Subinterfaces
    See Also:
      - `Class.getGenericInterfaces()`

  - ### signatureString

    String signatureString()
    Returns the raw signature string.
    Returns:
      the raw signature string

  - ### of

    static ClassSignature of(Signature.ClassTypeSig superclassSignature, Signature.ClassTypeSig... superinterfaceSignatures)
    Returns a class signature with no type parameter declaration.
    Parameters:
      `superclassSignature` - the superclass
      `superinterfaceSignatures` - the interfaces
    Returns:
      a class signature with no type parameter declaration

  - ### of

    static ClassSignature of(List<Signature.TypeParam> typeParameters, Signature.ClassTypeSig superclassSignature, Signature.ClassTypeSig... superinterfaceSignatures)
    Returns a class signature.
    Parameters:
      `typeParameters` - the type parameters, may be empty
      `superclassSignature` - the superclass
      `superinterfaceSignatures` - the interfaces
    Returns:
      a class signature

  - ### parseFrom

    static ClassSignature parseFrom(String classSignature)
    Parses a raw class signature string into a Signature.
    Parameters:
      `classSignature` - the raw class signature string
    Returns:
      class signature
    Throws:
      `IllegalArgumentException` - if the string is not a valid class signature string