[code-reflection] RFR: 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Dec 15 11:38:42 UTC 2025
This PR addresses an issue in for-each loop model generation.
The for each op factory takes three bodies:
1. the for each expression (e.g. either a collection, or an array)
2. the for each initializer (the logic that receives an element from the expression, and turns it into the expected variable type in the source code)
3. the for each body
The translation for (2) seems to contain a bug: javac erroneously assumes that the initializer body has type `(V)->V`, where `V` is the type of the induction variable declared in the source code.
This PR fixes that so that (2) has type `(ELEM)->V`, where `ELEM` is the static type of an element of the for-each expression, and `V` is the static type of the induction variable.
This translation allows uboxing operations to appear manifest in the generated model.
-------------
Commit messages:
- Add tests
- Initial push
Changes: https://git.openjdk.org/babylon/pull/750/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=750&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8373571
Stats: 79 lines in 2 files changed: 76 ins; 1 del; 2 mod
Patch: https://git.openjdk.org/babylon/pull/750.diff
Fetch: git fetch https://git.openjdk.org/babylon.git pull/750/head:pull/750
PR: https://git.openjdk.org/babylon/pull/750
More information about the babylon-dev
mailing list