[lworld] RFR: 8327695: [lworld] javac can generate incorrect code in inner class' constructors [v2]
Vicente Romero
vromero at openjdk.org
Mon Mar 18 14:22:57 UTC 2024
> When dealing with value classes javac, as mandated by the spec, is placing field initializers before any invocation to `super()`. This works just fine most of the time but for cases like:
>
> class JavacBug {
> value class V1 {}
>
> value class V2 {
> V1 v = new V1();
> }
>
> void test() {
> V2 v2 = new V2();
> }
>
> public static void main(String... args) {
> JavacBug jb = new JavacBug();
> jb.test();
> }
> }
>
> javac is generating incorrect code for class V2 due to a getfield being generated to read the synthetic field storing the outer this before invoking the constructor for V1. The proposed change is changing the generated bytecode to read the outer this from the mandated parameter javac adds to inner class constructors,
>
> TIA
Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
addressing review comments
-------------
Changes:
- all: https://git.openjdk.org/valhalla/pull/1048/files
- new: https://git.openjdk.org/valhalla/pull/1048/files/d582b997..7ae7829b
Webrevs:
- full: https://webrevs.openjdk.org/?repo=valhalla&pr=1048&range=01
- incr: https://webrevs.openjdk.org/?repo=valhalla&pr=1048&range=00-01
Stats: 4 lines in 1 file changed: 1 ins; 2 del; 1 mod
Patch: https://git.openjdk.org/valhalla/pull/1048.diff
Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1048/head:pull/1048
PR: https://git.openjdk.org/valhalla/pull/1048
More information about the valhalla-dev
mailing list