APIdia Launch Partner
Top Description Methods
java.lang.classfile

public sealed Interface MethodModel

extends CompoundElement<MethodElement>, AttributedElement, ClassElement
permits Model, MethodImpl
Known Direct Implementers
jdk.internal.classfile.impl.BufferedMethodBuilder.Model, jdk.internal.classfile.impl.MethodImpl
Imports
java.lang.classfile.constantpool.Utf8Entry, java.lang.constant.MethodTypeDesc, java.lang.reflect.AccessFlag, java.util.Optional, java.util.function.Consumer, jdk.internal.classfile.impl.BufferedMethodBuilder, .MethodImpl, .Util

Models a method. A method can be viewed as a composition of MethodElements, or by random access 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 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.

Since
24
Java Virtual Machine Specification
4.6 Methods
See Also
ClassModel#methods(), MethodTransform

Method Summary

Modifier and TypeMethod and Description
public Optional<CodeModel>

Returns:

the body of this method, if there is one
code
()

Returns the body of this method, if there is one.

public AccessFlags

Returns:

the access flags
flags
()

Returns the access flags.

public Utf8Entry

Returns:

the name of this method
methodName
()

Returns the name of this method.

public Utf8Entry

Returns:

the method descriptor string of this method
methodType
()

Returns the method descriptor string of this method.

public default MethodTypeDesc

Returns:

the method type, as a symbolic descriptor
methodTypeSymbol
()

Returns the method type, as a symbolic descriptor.

public Optional<ClassModel>

Returns:

the class model this method is a member of, if known
parent
()

Returns the class model this method is a member of, if known.

Inherited from java.lang.classfile.AttributedElement:
attributesfindAttributefindAttributes
Inherited from java.lang.classfile.CompoundElement:
elementListelementStreamforEachiteratortoDebugString

Method Detail

codeback to summary
public Optional<CodeModel> code()

Returns the body of this method, if there is one.

Returns:Optional<CodeModel>

the body of this method, if there is one

flagsback to summary
public AccessFlags flags()

Returns the access flags.

Returns:AccessFlags

the access flags

See Also
AccessFlag.Location#METHOD
methodNameback to summary
public Utf8Entry methodName()

Returns the name of this method.

Returns:Utf8Entry

the name of this method

methodTypeback to summary
public Utf8Entry methodType()

Returns the method descriptor string of this method.

Returns:Utf8Entry

the method descriptor string of this method

methodTypeSymbolback to summary
public default MethodTypeDesc methodTypeSymbol()

Returns the method type, as a symbolic descriptor.

Returns:MethodTypeDesc

the method type, as a symbolic descriptor

parentback to summary
public Optional<ClassModel> parent()

Returns the class model this method is a member of, if known.

Returns:Optional<ClassModel>

the class model this method is a member of, if known