RFR: 8344841: ClassPrinter prints confusing value for null

Chen Liang liach at openjdk.org
Fri Nov 22 16:54:19 UTC 2024


On Fri, 22 Nov 2024 10:24:12 GMT, Adam Sotona <asotona at openjdk.org> wrote:

> ClassPrinter prints `null` values as `String` "null" or as `String.valueOf(ConstantDescs.BSM_NULL_CONSTANT)`, based on context.
> 
> This patch unifies handling of `null` values.
> They are now exclusively represented as `ConstantDescs.BSM_NULL_CONSTANT`.
> In Json and Yaml format is `null` value printed unquoted and in Xml as `<null/>`.
> In Json and Yaml is `"null"` `String` printed quoted to distinguish from the `null` value.
> 
> Please review.
> 
> Thank you,
> Adam

src/java.base/share/classes/jdk/internal/classfile/impl/ClassPrinterImpl.java line 950:

> 948:                             "class", ema.enclosingClass().name().stringValue(),
> 949:                             "method name", ema.enclosingMethodName()
> 950:                                     .map((Function<Utf8Entry, ConstantDesc>)Utf8Entry::stringValue).orElse(BSM_NULL_CONSTANT),

Suggestion:

                                    .<ConstantDesc>map(Utf8Entry::stringValue).orElse(BSM_NULL_CONSTANT),

same for other casts.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22316#discussion_r1854282261


More information about the core-libs-dev mailing list