On Tue, 4 Aug 2026 00:07:47 GMT, Chen Liang <[email protected]> wrote:

> Currently, it's hard for users to inspect the preview-specific class files in 
> the JDK with javap. There's a hidden option from the base file manager, 
> `--preview-mode`, that accomplishes this, but this option is cursed by the 
> fact that it consumes arbitrary string arguments that do not represent a 
> valid boolean, causing confusions when it accidentally consumes subsequent 
> flags or arguments. We should tweak this option to reject whatever is not 
> `true` or `false`, and document this option for the `javap` tool, and 
> document in `value-class-preview.md`. (This is already documented in 
> `javac.properties`)
> 
> Currently, on mainline, you can already do: (`=` can be replaced with a space)
> 
> javap --preview-mode=true java.lang.Integer
> 
> 
> to obtain the disassembly for the preview `Integer` class.
> 
> However, an erroneous command line like:
> 
> javap --preview-mode java.lang.Integer
> 
> 
> fails with an ambiguous message, because the parser tries to parse 
> `java.lang.Integer` as a boolean value. This patch makes the error message 
> more clear, as demonstrated in the new test.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

1. Please don't add `--enable-preview` to javap. Even though it makes sense in 
the JDK 28 realm as "enable examination of the preview-specific version of a 
class file", it doesn't make sense more generally. In particular, javap 
offering `--enable-preview` would suggest that it's used to examine a new 
preview API such as `java.lang.Record` was in Java 14 ... but it's deliberately 
not necessary to pass any options to examine new APIs like that.
2. The name `-preview-mode` needs to be rethought for a documented, supported 
option. Preview features are not a "mode"; they are standard features of the 
Java Platform that happen to be disabled by default. You are never in a "mode" 
where you have preview features alone. Consider `--preview-version 
java.lang.Integer` and drop the true/false argument.
3. I altered the CSR's Description to be more informative, and to observe that 
you need a specification for javap's help output and its man page. (I did not 
alter the option name or syntax.)
4. The "Compatibility Risk Description" of the CSR is very hard to understand.

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

PR Comment: https://git.openjdk.org/jdk/pull/32186#issuecomment-5181819533

Reply via email to