AttributedElement, ClassElement, ClassFileElement, CompoundElement<MethodElement>, Iterable<MethodElement>public sealed interface MethodModel extends CompoundElement<MethodElement>, AttributedElement, ClassElement
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(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.
| Modifier and Type | Method | Description |
|---|---|---|
Optional |
code() |
Returns the body of this method, if there is one. |
AccessFlags |
flags() |
Returns the access flags. |
Utf8Entry |
methodName() |
Returns the name of this method. |
Utf8Entry |
methodType() |
Returns the method descriptor string of this method. |
default MethodTypeDesc |
methodTypeSymbol() |
Returns the method type, as a symbolic descriptor. |
Optional |
parent() |
Returns the class model this method is a member of, if known. |
attributes, findAttribute, findAttributes
elementList, elementStream, forEach, iterator, toDebugString
spliterator
AccessFlags flags()
Optional<ClassModel> parent()
Utf8Entry methodName()
Utf8Entry methodType()
default MethodTypeDesc methodTypeSymbol()
Optional<CodeModel> code()
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/classfile/MethodModel.html