RFR: 8035271: Incorrect indentation of LineNumberTable/LocalVariableTable/Exception table/LocalVariableTypeTable/StackMapTable/RuntimeVisibleTypeAnnotations in verbose mode

Jonathan Lampérth duke at openjdk.org
Tue Nov 26 09:14:37 UTC 2024


On Mon, 25 Nov 2024 16:01:43 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> > > Add code header for only -l case?
> 
> I also like this option, because it maintains the "nesting" of attributes - e.g. the main thing here is that LNT and LVT are attributes of Code, so they should be nested in there. One option could be to report the general number of opcodes in the Code attribute, if no `-c` is provided (so that at least that can be used as a guidance for interpreting the other attributes).


Do you mean comething as simple as this just counting the number of instructions?

### `javap -l EmptyLoop`

Compiled from "EmptyLoop.java"
public class EmptyLoop {
  public EmptyLoop();
    Code:
      Opcode count: 3
      LineNumberTable:
        line 1: 0

  public void emptyLoop();
    Code:
      Opcode count: 8
      LineNumberTable:
        line 3: 0
        line 5: 14
}


<details>
<summary>With code for context: `javap -l -c EmptyLoop`</summary>


Compiled from "EmptyLoop.java"
public class EmptyLoop {
  public EmptyLoop();
    Code:
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 1: 0

  public void emptyLoop();
    Code:
         0: iconst_0
         1: istore_1
         2: iload_1
         3: bipush        10
         5: if_icmpge     14
         8: iinc          1, 1
        11: goto          2
        14: return
      LineNumberTable:
        line 3: 0
        line 5: 14
}


</details>

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22359#issuecomment-2500067046


More information about the core-libs-dev mailing list