pub struct Method<'a> { /* private fields */ }Expand description
A borrowed view of a method declaration and its optional code.
Implementations§
Source§impl<'a> Method<'a>
impl<'a> Method<'a>
Sourcepub fn access_flags(&self) -> u16
pub fn access_flags(&self) -> u16
Returns the raw method access-flag bitset.
Sourcepub fn descriptor(&self) -> &str
pub fn descriptor(&self) -> &str
Returns the JVM method descriptor.
Sourcepub fn has_code(&self) -> bool
pub fn has_code(&self) -> bool
Returns whether this method has a Code attribute.
Abstract and native methods normally return false.
Sourcepub fn max_stack(&self) -> u16
pub fn max_stack(&self) -> u16
Returns the Code attribute’s declared maximum operand-stack depth.
Returns zero for methods without code.
Sourcepub fn max_locals(&self) -> u16
pub fn max_locals(&self) -> u16
Returns the Code attribute’s declared maximum local-variable count.
Returns zero for methods without code.
Sourcepub fn instructions(
&self,
) -> Option<impl ExactSizeIterator<Item = Instruction<'a>> + '_>
pub fn instructions( &self, ) -> Option<impl ExactSizeIterator<Item = Instruction<'a>> + '_>
Iterates over bytecode instructions in original order when code is present.
Returns None for methods without a Code attribute. Each instruction retains its
original bytecode offset and borrows from this method.
Sourcepub fn exception_handlers(
&self,
) -> impl ExactSizeIterator<Item = ExceptionHandler<'a>> + '_
pub fn exception_handlers( &self, ) -> impl ExactSizeIterator<Item = ExceptionHandler<'a>> + '_
Iterates over exception-table entries in class-file order.
Methods without code return an empty iterator.
Sourcepub fn stack_map_frames(
&self,
) -> Option<impl ExactSizeIterator<Item = StackMapFrame<'a>> + '_>
pub fn stack_map_frames( &self, ) -> Option<impl ExactSizeIterator<Item = StackMapFrame<'a>> + '_>
Iterates over StackMapTable frames when the method has that attribute.
The class-file format stores frames as deltas from preceding frames. The returned views preserve that encoding and resolve object verification types against the method’s constant pool.