On 10/31/2017 1:47 AM, Remi Forax wrote:
Hi all, the spec of the Runtime*ParameterAnnotations attribute [1],
allow the number of parameter annotations to be different from the
number of parameter from the method descriptor but it fails to
provide a way to retrieve/compute the mapping between a parameter and
a parameter annotation.
So people try to guess and fail, here is by example the ASM bug when
we tried to provide such mapping to our user [2].
We (the ASM team) believe the only way to fix that is to require that
if the number of parameters from the descriptor and the number of
parameter annotations doesn't match then compilers should also emit a
Parameter attribute which already indicate if a parameter is
synthetic or not.
I recognize that constructor parameters are a painful cause of
discrepancy between the method descriptor and various attributes -- not
just Runtime*ParameterAnnotations but also Signature (see the note "A
method signature encoded by ..." in
https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.9.1).
However, the decision in JDK-8067975 was to loosen the JVMS' description
so that it admitted the class files emitted by javac and ecj. If you
want javac and ecj to emit something different than they do today, then
your best bet is to write up a "State of the Parameters" page that shows
the "interesting" programs, and what javac and ecj emit. Only then can
suggestions like "Emit a MethodParameters attribute if ..." be evaluated.
Alex