Module java.base
Package java.lang.classfile

# Interface MethodBuilder

≠
public abstract sealed interface MethodBuilder
extends java.lang.classfile.ClassFileBuilder<java.lang.classfile.MethodElement, java.lang.classfile.MethodBuilder>
permits jdk.internal.classfile.impl.ChainedMethodBuilder, jdk.internal.classfile.impl.TerminalMethodBuilder
Comparing master and cf

All Superinterfaces:
  `ClassFileBuilder<MethodElement, MethodBuilder>, Consumer<MethodElement>`

public sealed interface MethodBuilder extends ClassFileBuilder<MethodElement, MethodBuilder>
A builder for methods. Builders are not created directly; they are passed to handlers by methods such as The main way to obtain a method builder is via `Moved out of a link with destination ClassBuilder.html#withMethod(java.lang.classfile.constantpool.Utf8Entry,java.lang.classfile.constantpool.Utf8Entry,int,java.util.function.Consumer).Moved to a link with destination ClassBuilder.html#withMethod(java.lang.String,java.lang.constant.MethodTypeDesc,int,java.util.function.Consumer).ClassBuilder.withMethod(` Utf8Entry `StringMoved out of a link with destination ClassBuilder.html#withMethod(java.lang.classfile.constantpool.Utf8Entry,java.lang.classfile.constantpool.Utf8Entry,int,java.util.function.Consumer).Moved to a link with destination ClassBuilder.html#withMethod(java.lang.String,java.lang.constant.MethodTypeDesc,int,java.util.function.Consumer).,` Utf8Entry `MethodTypeDescMoved out of a link with destination ClassBuilder.html#withMethod(java.lang.classfile.constantpool.Utf8Entry,java.lang.classfile.constantpool.Utf8Entry,int,java.util.function.Consumer).Moved to a link with destination ClassBuilder.html#withMethod(java.lang.String,java.lang.constant.MethodTypeDesc,int,java.util.function.Consumer)., int, Consumer)` or to method transforms. The elements of a method can be specified abstractly (by passing a `MethodElement` to `ClassFileBuilder.with(ClassFileElement)` or concretely by calling the various `withXxx` methods.. `ClassBuilder.withMethodBody(String, MethodTypeDesc, int, Consumer)` is useful if no attribute on the method except `Code` needs to be configured, skipping the method handler.

Refer to `ClassFileBuilder` for general guidance and caution around the use of builders for structures in the `class` file format.

See Java Virtual Machine Specification:
  4.6 Methods
Since:
  24
See Also:
  - `MethodModel`
  - `MethodTransform`

## Methods

- ≠
  public abstract java.lang.classfile.MethodBuilder transformCode(java.lang.classfile.CodeModel arg0, java.lang.classfile.CodeTransform arg1)
  Comparing master and cf

  ### transformCode

  MethodBuilder transformCode (CodeModel code, CodeTransform transform)
  Build the method body for this method by transforming the body of another method.

  Moved to a paragraph.

  Implementation Note:

  Moved out of a definition list with class notes.Moved out of a definition.Moved to a division with class block. Moved out of a definition list with class notes.Moved out of a definition.Moved to a division with class block.This method behaves as if:

  Moved out of a definition list with class notes.Moved out of a definition.Moved to a division with class block.

      Moved out of a definition list with class notes.Moved out of a definition.Moved to a division with class block.

      Moved out of a definition list with class notes.Moved out of a definition.Moved to a division with class block.withCode(

  b

      cobMoved out of a definition list with class notes.Moved out of a definition.Moved to a division with class block. ->

  b

      cobMoved out of a definition list with class notes.Moved out of a definition.Moved to a division with class block..

  transformCode

      transformMoved out of a definition list with class notes.Moved out of a definition.Moved to a division with class block.(code, transform));

      Moved out of a definition list with class notes.Moved out of a definition.Moved to a division with class block.

  Parameters:
    `code` - the method body to be transformed
    `transform` - the transform to apply to the method body
  Returns:
    this builder
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `CodeTransform`
- ≠
  public abstract java.lang.classfile.MethodBuilder withCode(java.util.function.Consumer<? super java.lang.classfile.CodeBuilder> arg0)
  Comparing master and cf

  ### withCode

  MethodBuilder withCode (Consumer<? super CodeBuilder> code)
  Build the method body for this method.
  Parameters:
    `code` - a handler receiving a `CodeBuilder`
  Returns:
    this builder
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `CodeModel`
- ≠
  public default java.lang.classfile.MethodBuilder withFlags(int arg0)
  Comparing master and cf

  ### withFlags

  default MethodBuilder withFlags (int flags)
  Sets the method access flags. The `AccessFlag.STATIC` flag cannot be modified after the builder is created.
  Parameters:
    `flags` - the access flags, as a bit mask
  Returns:
    this builder
  Throws:
    `IllegalArgumentException` - if the `ACC_STATIC` flag is modified
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `AccessFlags`
    - `AccessFlag.Location.METHOD`
- =
  public default java.lang.classfile.MethodBuilder withFlags(java.lang.reflect.AccessFlag[] arg0)

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
MethodBuilder |  |  |  |  |  |  | 3 | 2 | 5 | 10
transformCode(CodeModel,CodeTransform) |  |  |  |  |  |  | 5 | 1 | 6 | 12
withCode(Consumer) |  |  |  |  |  |  | 5 |  |  | 5
withFlags(int) |  |  |  |  |  |  | 9 |  |  | 9
Total |  |  |  |  |  |  | 22 | 3 | 11 | 36