Module java.base
Package java.lang.classfile

# Interface MethodModel

≠
public abstract sealed interface MethodModel
extends java.lang.classfile.AttributedElement, java.lang.classfile.ClassElement, java.lang.classfile.CompoundElement<java.lang.classfile.MethodElement>
permits jdk.internal.classfile.impl.MethodImpl, jdk.internal.classfile.impl.BufferedMethodBuilder.Model
Comparing master and cf

All Superinterfaces:
  `AttributedElement, ClassElement, ClassFileElement, CompoundElement<MethodElement>, Iterable<MethodElement>`

public sealed interface MethodModel extends CompoundElement<MethodElement>, AttributedElement, ClassElement
Models a method. The contents of the A method can be traversed via a streaming viewviewed as a composition of `MethodElement` s, or via by random access (e.g., `flags()` ), or by freely mixing the two.

Since:
  24

via accessor methods if only specific parts of the method is needed.

Methods can be obtained from `ClassModel.methods()` , or in the traversal of member elements of a class.

`ClassBuilder.withMethod(String, MethodTypeDesc, int, Consumer)` is the main way to construct methods. `ClassBuilder.transformMethod(MethodModel, MethodTransform)` allows creating a new method by selectively processing the original method elements and directing the results to a method builder.

All method attributes are accessible as member elements.

See Java Virtual Machine Specification:
  4.6 Methods
Since:
  24
See Also:
  - `ClassModel.methods()`
  - `MethodTransform`

## Methods

- =
  public abstract java.util.Optional<java.lang.classfile.CodeModel> code()
- ≠
  public abstract java.lang.classfile.AccessFlags flags()
  Comparing master and cf

  ### flags

  AccessFlags flags()
  Returns the access flags.
  Returns:
    the access flags
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `AccessFlag.Location.METHOD`
- =
  public abstract java.lang.classfile.constantpool.Utf8Entry methodName()
- ≠
  public abstract java.lang.classfile.constantpool.Utf8Entry methodType()
  Comparing master and cf

  ### methodType

  Utf8Entry methodType()
  Returns the method descriptor string of this method.
  Returns:
    the method descriptor string of this method
- ≠
  public default java.lang.constant.MethodTypeDesc methodTypeSymbol()
  Comparing master and cf

  ### methodTypeSymbol

  default MethodTypeDesc methodTypeSymbol()
  Returns the method descriptor of this methodtype, as a symbolic descriptor.
  Returns:
    the method descriptor of this methodtype, as a symbolic descriptor
- =
  public abstract java.util.Optional<java.lang.classfile.ClassModel> parent()

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
MethodModel |  |  |  |  |  |  | 5 | 3 | 4 | 12
flags() |  |  |  |  |  |  | 5 |  |  | 5
methodType() |  |  |  |  |  |  | 2 |  |  | 2
methodTypeSymbol() |  |  |  |  |  |  |  | 2 |  | 2
Total |  |  |  |  |  |  | 12 | 5 | 4 | 21