Class JavapSectionExtractor
java.lang.Object
org.ek9lang.compiler.backend.jvm.JavapSectionExtractor
- All Implemented Interfaces:
BiFunction<String,String, String>
THE indentation-aware slicer for
javap -v -p -l output — the shared helper that both
BytecodeNormalizer (strip a section) and the @DEBUG directive (keep a section) build
on. It exists because the lookahead strip regexes in BytecodeNormalizer
((?s)LocalVariableTable:.*?(?=\n\n|\n +|\n})}) mis-slice: javap prints
LineNumberTable / LocalVariableTable / StackMapTable contiguously with no
blank line between them, so a lookahead that stops at the next blank line swallows the following
sibling section. Slicing by INDENTATION is robust to that (Wave-1 A.0; see
docs/strategic/SPEC-agentic-debugger.md §9.2).
A "section" is a header line whose trimmed text is <Name>: (e.g. LocalVariableTable:,
LineNumberTable:, SourceDebugExtension:) plus every following line indented MORE
deeply than the header. The section ends at the first line whose indentation is less-than-or-equal to
the header's (a sibling section, the enclosing Code:'s next item, or a method/class
boundary), or at a blank line — javap never puts a blank inside a section body. A class can contain
many occurrences of the same section (one LocalVariableTable per method); all are returned in
source order.
Hold one; the occurrences themselves are JavapSectionOccurrences.
-
Constructor Details
-
JavapSectionExtractor
public JavapSectionExtractor()
-
-
Method Details
-
apply
Every occurrence of the named section (header + its indented body), in order, each terminated by a newline. Empty string when the section does not occur (e.g. noLocalVariableTablewas emitted).sectionNameis the header word without the colon, e.g."LocalVariableTable".- Specified by:
applyin interfaceBiFunction<String,String, String>
-