RFR: 8263763: Synthetic constructor parameters of enum are not considered for annotation indices
Joe Darcy
darcy at openjdk.java.net
Fri Mar 19 05:27:38 UTC 2021
On Thu, 18 Mar 2021 21:03:20 GMT, Rafael Winterhalter <winterhalter at openjdk.org> wrote:
> 8263763: The constructor of an enumeration prefixes with two synthetic arguments for constant name and ordinal index. For this reason, the constructor annotations need to be shifted two indices to the right, such that the annotation indices match with the parameter indices.
A general comment, the enum constructor situation is a bit tricky as
1) There is no 100% reliable way to determine which of a enum constructor's args are synthetic.
2) How a Java compiler generates enum constructors is a compiler-internal contract since all the enum constructors must be private.
It is true that javac has consistently added two extra parameters as an implementation detail. Offhand, I don't know if ecj in particular has made the same choice. javac is not obliged to continue implementing enum constructors in this manner, so for better robustness, I think a fix in this space needs to be able to accommodate situations other than exactly N+2 parameters.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3082
More information about the core-libs-dev
mailing list