RFR: 8332600: javac uses record components source position during compilation [v2]
Vicente Romero
vromero at openjdk.org
Fri Jul 12 20:24:23 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
Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
review comments
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/20148/files
- new: https://git.openjdk.org/jdk/pull/20148/files/49d0ad16..e7647e22
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=20148&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=20148&range=00-01
Stats: 42 lines in 4 files changed: 22 ins; 12 del; 8 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