[lworld] RFR: 8327695: [lworld] javac can generate incorrect code in inner class' constructors
Vicente Romero
vromero at openjdk.org
Fri Mar 15 15:47:49 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
-------------
Commit messages:
- 8327695: [lworld] javac can generate incorrect code in inner class' constructors
Changes: https://git.openjdk.org/valhalla/pull/1048/files
Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1048&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8327695
Stats: 59 lines in 4 files changed: 53 ins; 0 del; 6 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