Class LvtSupport


  • public final class LvtSupport
    extends Object
    Shared primitives for emitting LocalVariableTable entries, used by both LVT builders.
    • Method Detail

      • entry

        public static LocalVariableTableEntry entry​(ConstPool constPool,
                                                    int slot,
                                                    String name,
                                                    String descriptor,
                                                    int startPc,
                                                    int length)
        Builds an entry, resolving the name + descriptor to UTF-8 constant-pool indices.
        Parameters:
        constPool - the pool the UTF-8 entries are added to
        slot - the local variable slot
        name - the variable name
        descriptor - the variable's field descriptor
        startPc - the first code offset the entry covers
        length - the number of bytes the entry covers
        Returns:
        the built entry
      • valid

        public static boolean valid​(int slot,
                                    int maxLocals,
                                    int startPc,
                                    int length,
                                    int codeLength)
        True when an entry is well-formed: slot in range and scope wholly within the code.
        Parameters:
        slot - the local variable slot
        maxLocals - the method's local slot count
        startPc - the first code offset the entry covers
        length - the number of bytes the entry covers
        codeLength - the method's code length
        Returns:
        true when the slot and the scope are both in range
      • dropSameSlotOverlaps

        public static void dropSameSlotOverlaps​(List<LocalVariableTableEntry> entries)
        Drops any same-slot entry whose scope overlaps an already-kept one (keeps the earlier entry).
        Parameters:
        entries - the entry list, rewritten in place