Class CodeStackTrackerImpl

java.lang.Object
org.glavo.classfile.impl.CodeStackTrackerImpl
All Implemented Interfaces:
ClassFileTransform<CodeTransform,CodeElement,CodeBuilder>, CodeTransform, CodeStackTracker

public final class CodeStackTrackerImpl extends Object implements CodeStackTracker
  • Constructor Details

    • CodeStackTrackerImpl

      public CodeStackTrackerImpl(TypeKind... initialStack)
  • Method Details

    • stack

      public Optional<Collection<TypeKind>> stack()
      Description copied from interface: CodeStackTracker
      Returns Collection of TypeKind representing current stack. Returns an empty Optional when the Stack content is unknown (right after xRETURN, ATHROW, GOTO, GOTO_W, LOOKUPSWITCH, TABLESWITCH instructions).

      Temporary unknown stack content can be recovered by binding of a Label used as target of a branch instruction from existing code with known stack (forward branch target), or by binding of a Label defining an exception handler (exception handler code start).

      Specified by:
      stack in interface CodeStackTracker
      Returns:
      actual stack content, or an empty Optional if unknown
    • maxStackSize

      public Optional<Integer> maxStackSize()
      Description copied from interface: CodeStackTracker
      Returns tracked max stack size. Returns an empty Optional when max stack size tracking has been lost.

      Max stack size tracking is permanently lost when a stack instruction appears and the actual stack content is unknown.

      Specified by:
      maxStackSize in interface CodeStackTracker
      Returns:
      tracked max stack size, or an empty Optional if tracking has been lost
    • accept

      public void accept(CodeBuilder cb, CodeElement el)
      Description copied from interface: ClassFileTransform
      Transform an element by taking the appropriate actions on the builder. Used when transforming a classfile entity (class, method, field, method body.) If no transformation is desired, the element can be presented to ClassFileBuilder.with(ClassFileElement). If the element is to be dropped, no action is required.
      Specified by:
      accept in interface ClassFileTransform<CodeTransform,CodeElement,CodeBuilder>
      Parameters:
      cb - the builder for the new entity
      el - the element