RFR: 8332600: javac uses record components source position during compilation
Vicente Romero
vromero at openjdk.org
Thu Jul 11 21:43:16 UTC 2024
javac uses the source position of record components to find and later probably remove a given record component during compilation. This could be necessary if annotation processors are present. This is done in part to provide better error messages for silly record definitions like:
record R(int i, float i) {} // two record components with the same name
but this is brittle and can backfire if the record is read from a class file as the source positions are not stored there. See [JDK-8332297](https://bugs.openjdk.org/browse/JDK-8332297) for some context
The idea of this fix is not to use the source position but only the name to find a given record component. This could imply that if the user defines an erroneous record like the one above, then the record could end up with less record components than expected but records like this wouldn't compile anyway
TIA
-------------
Commit messages:
- 8332600: javac uses record components source position during compilation
Changes: https://git.openjdk.org/jdk/pull/20148/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20148&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8332600
Stats: 11 lines in 4 files changed: 2 ins; 5 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/20148.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20148/head:pull/20148
PR: https://git.openjdk.org/jdk/pull/20148
More information about the compiler-dev
mailing list