On Thu, 28 Nov 2024 11:33:43 GMT, Jonathan Lampérth <d...@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

I made a change to `javap.properties` to make this new change in behaviour more 
clear in the documentation. 
I just noticed that there is also `javap_de.properties`, `javap_ja.properties` 
and `javap_zh_CN.properties`, which I have not touched.

I guess leaving out my change in english might be best, to avoid inconsitency 
between translations? Likely this extra info doesn't provide much value, as one 
gets the same insight in the warning.

Note: It seems this approach is taken for other cases of incompatible 
arguments. For example in the case `-public`, `-protected` there is an Error, 
but no information about the incompatibility in the help output from 
`javap.properties`:


javap -l -c -private -public EmptyLoop
Error: bad combination of options: -private -public

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

PR Comment: https://git.openjdk.org/jdk/pull/22434#issuecomment-2506441495

Reply via email to