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).

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

Commit messages:
 - 8389654

Changes: https://git.openjdk.org/jdk/pull/32186/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=32186&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8389654
  Stats: 114 lines in 7 files changed: 97 ins; 1 del; 16 mod
  Patch: https://git.openjdk.org/jdk/pull/32186.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/32186/head:pull/32186

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

Reply via email to