RFR: 8358078: javap crashes with NPE on preview class file [v2]
Chen Liang
liach at openjdk.org
Mon Jun 2 17:32:54 UTC 2025
On Mon, 2 Jun 2025 16:59:34 GMT, Hannes Greule <hgreule at openjdk.org> wrote:
>> This change addresses a NPE in javap when trying to print a class with minorVersion != 0. With this change, we fall back to the methods that don't take a `ClassFileFormatVersion` in such case.
>
> Hannes Greule has updated the pull request incrementally with one additional commit since the last revision:
>
> don't return null but latest as fallback
test/langtools/tools/javap/ClassFileVersionTest.java line 85:
> 83: @ParameterizedTest
> 84: @MethodSource("classFiles")
> 85: void test(byte[] classFile, boolean shouldError) throws Throwable {
I recommend adding another String argument indicating the case name - otherwise, if junit fails, the error message reports the argument to string, which is not informative on which class file exactly is being tested.
An alternative approach can be inlining the arguments to `createClassFile` to the case arguments, like
void test(boolean shouldError, int major, int minor, AccessFlag... classFlags)
And junit provides a more useful error message for such arguments.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25569#discussion_r2121764380
More information about the compiler-dev
mailing list