Class MethodKindIndex

java.lang.Object
org.ek9lang.compiler.backend.jvm.debug.MethodKindIndex

public final class MethodKindIndex extends Object
The debug-time reader of one class's Ek9MethodKinds attribute (C.2): parses the class bytes into a (method name + descriptor) -> Ek9MethodKind / MethodDebugPolicy lookup. This is the INPUT half of the F.3 step filter - StepFilter turns the policy bits it returns into stepping decisions. See docs/strategic/EK9_DEBUGGER_STRATEGY.md §18 and the F.3 row of docs/implementation/EK9_DEBUGGER_IMPLEMENTATION_PLAN.md.

Why read the bytes, not JDI. JDI's ReferenceType exposes fields/methods/source but NOT arbitrary class attributes, so the semantics layer cannot ask JDWP "what is this method's kind". It must read the .class bytes (from the .ek9 output the debuggee loaded) with ASM, registering an Ek9MethodKindsAttribute prototype - exactly as the tagging tests do. One index per class; the debug runtime will cache them per loaded ReferenceType.

The user-code default is the whole point. A method with no entry is ordinary user code, so policyFor(String, String) returns MethodDebugPolicy.USER_CODE for it - fully shown, fully steppable. That collapses "is this user code?" and "what does the tag say?" into ONE bit-test path in the filter, with no special-casing.

  • Method Details

    • fromClassBytes

      public static MethodKindIndex fromClassBytes(byte[] classBytes)
      Parse a class's Ek9MethodKinds attribute out of its raw bytes. A class with no such attribute (all user code, or a non-EK9 class) yields an empty index - every lookup then falls back to MethodDebugPolicy.USER_CODE.
    • className

      public String className()
      The JVM internal name of the class this index was read from (e.g. bytecode/test/Point).
    • isEmpty

      public boolean isEmpty()
      True when the class carried no tagged methods (nothing recorded ⇒ all user code).
    • entryFor

      public Optional<Ek9MethodKindsAttribute.Entry> entryFor(String name, String descriptor)
      The recorded entry for a method, or empty when it has none (user code). Callers that only need the stepping decision should prefer policyFor(String, String); the entry is for frame re-presentation, which also needs the Ek9MethodKind.
    • policyFor

      public int policyFor(String name, String descriptor)
      THE step-filter input: the MethodDebugPolicy bitset for a method, defaulting to MethodDebugPolicy.USER_CODE when the method has no entry (user code is fully shown/steppable). This is what StepFilter consumes.
    • kindFor

      public Optional<Ek9MethodKind> kindFor(String name, String descriptor)
      The recorded Ek9MethodKind for a method (drives frame re-presentation), or empty when the method is user code or the wire code is unknown to this version.