[code-reflection] RFR: Fails if code model was compiled by a feature version different from the current [v2]

Paul Sandoz psandoz at openjdk.org
Tue Dec 9 20:19:40 UTC 2025


On Tue, 9 Dec 2025 16:43:41 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:

>> Before we build a code model, we check if the Java feature version used to compile the code model matches the current one. In case there's no match, we throw an exception.
>
> Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Apply Paul's comments

Much better. Any thoughts on how to test this? We could modify the bytecode of the class afterwards to replace the constant pool entry with a different version?

src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/OpBuilder.java line 179:

> 177:             J_L_OBJECT); // body definition(s): Body.Builder, List<Body.Builder> or null
> 178: 
> 179:     static final MethodRef STRING_FORMAT = MethodRef.method(String.class, "format", String.class, String.class,

Unused.

src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/OpBuilder.java line 429:

> 427:     FuncOp build(String name, Op op) {
> 428:         Value ancestorBody = builder.op(constant(type(Body.Builder.class), null));
> 429:         // check if java version at compile time matches the java version at runtime

Now we have the right code shape we could move this to a static helper method rather that repeating the logic.

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

PR Review: https://git.openjdk.org/babylon/pull/738#pullrequestreview-3559265353
PR Review Comment: https://git.openjdk.org/babylon/pull/738#discussion_r2604011114
PR Review Comment: https://git.openjdk.org/babylon/pull/738#discussion_r2604192181


More information about the babylon-dev mailing list