Integrated: 8345145: Display javap LineNumberTable and LocalVariableTable iff disassembled code output with `-c` or `-v`

Jonathan Lampérth duke at openjdk.org
Fri Nov 29 16:26:47 UTC 2024


On Thu, 28 Nov 2024 11:33:43 GMT, Jonathan Lampérth <duke at openjdk.org> wrote:

> This PR includes a suggested change in behaviour of `javap -l` without `-v` or `-c`.
> Previously it was possible to print `LineNumberTable` and `LocalVariableTable` without disassembled code output. This didn't make much sense, as there is no context for this output. This PR proposes to output a warning for this case, as well as not print the `LineNumberTable`and `LocalVariableTable` attrubutes. They are nested attributes of the `CodeAttribute` and thus should only be printed if the `CodeAttribute`  is also printed.
> 
> Small changes were also made to existing tests, which seem unproblematic to adjust.
> 
> <details>
> <summary>Before: `javac -l EmptyLoop`</summary>
> 
> 
> Compiled from "EmptyLoop.java"
> public class EmptyLoop {
>   public EmptyLoop();
>     Code:
>       LineNumberTable:
>         line 1: 0
> 
>   public void emptyLoop();
>     Code:
>       LineNumberTable:
>         line 3: 0
>         line 5: 14
> }
> 
> 
> </details>
> 
> <details>
> <summary>After: `javac -l EmptyLoop`</summary>
> 
> 
> Warning: bad combination of options: -l without -c - line number and local variable tables will not be printed
> Compiled from "EmptyLoop.java"
> public class EmptyLoop {
>   public EmptyLoop();
> 
>   public void emptyLoop();
> }
> 
> 
> </details>
> 
> Stems from discussion in: https://github.com/openjdk/jdk/pull/22359

This pull request has now been integrated.

Changeset: ed03f0d9
Author:    Jonathan Lampérth <jonathan.lamperth at oracle.com>
Committer: Chen Liang <liach at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/ed03f0d9d10518242a3dc6e3685f1bdb0550c723
Stats:     118 lines in 8 files changed: 105 ins; 5 del; 8 mod

8345145: Display javap LineNumberTable and LocalVariableTable iff disassembled code output with `-c` or `-v`

Reviewed-by: mcimadamore, liach

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

PR: https://git.openjdk.org/jdk/pull/22434


More information about the core-libs-dev mailing list