RFR: 8333748: javap crash - Fatal error: Unmatched bit position 0x2 for location CLASS [v3]

Adam Sotona asotona at openjdk.org
Mon Jun 17 15:13:12 UTC 2024


On Mon, 17 Jun 2024 13:55:41 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Currently, javap crashes for class files that have set non-zero values for undefined access flag bits, as `java.lang.reflect.AccessFlag.maskToAccessFlag` and `java.lang.classfile.AccessFlags.flags` fail. In contrast, the JVMS, though asking for these bits to be set to 0, requires VM to proceed and ignore these bits. javap should emulate the VM behavior and proceed rendering, ignoring these undefined bits.
>> 
>> In addition, a few bytecode generation utilities in the JDK set unused bits, such as in `java.lang.invoke.MethodHandleImpl.BindCaller#generateInvokerTemplate` and `java.lang.invoke.GenerateJLIClassesHelper#generateCodeBytesForLFs`. Those can be updated in a later cleanup.
>
> Chen Liang has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Improve tests to check unmatched bit position and failure for non-inner-classes
>  - Report error for flag problems

test/langtools/tools/javap/UndefinedAccessFlagTest.java line 105:

> 103:             .writeAll()
> 104:             .getOutputLines(Task.OutputKind.DIRECT);
> 105:         assertTrue(lines.stream().anyMatch(l -> l.contains("Unmatched bit position")), () -> String.join("\n", lines));

I would add a check the "fatal" error does not occur or any other way to confirm correct recovery.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19708#discussion_r1642972527


More information about the compiler-dev mailing list