On Thu, 3 Dec 2026 02:30:34 GMT, xiaotaonan <[email protected]> wrote:

>> The Classfile API verifier (`VerifierImpl`) currently skips methods marked 
>> with `ACC_BRIDGE` during verification. This is inconsistent with HotSpot's 
>> verifier, which only skips overpass methods (VM-generated) and still 
>> verifies ordinary bridge methods.
>> 
>> A maliciously crafted class file could therefore mark a method with 
>> `ACC_BRIDGE` to bypass verification entirely.
>> 
>> This fix aligns the Classfile API verifier with HotSpot by replacing the 
>> `isBridge()` check with an equivalent overpass check.
>> 
>> Testing:
>> - Added a regression test that constructs a class file with an invalid 
>> method body marked `ACC_BRIDGE`, and verifies that the Classfile API 
>> verifier now rejects it.
>> - Ran the existing `java/lang/classfile` and `jdk/internal/classfile` tests.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> xiaotaonan has updated the pull request incrementally with two additional 
> commits since the last revision:
> 
>  - fix: Modify according to the review comments.
>  - fix: Modify according to the review comments.

test/jdk/jdk/classfile/VerifierSelfTest.java line 648:

> 646:         List<VerifyError> errors = ClassFile.of().verify(bytes);
> 647:         if (errors.isEmpty()) {
> 648:             throw new AssertionError("Expected verification error for 
> ACC_BRIDGE method with invalid bytecode, but verifier skipped it");

Nit - since this is a junit test, it should ideally use the 
`Assertions.assert...` APIs instead of throwing `AssertionError`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/34176#discussion_r4780979132

Reply via email to