| Newsgroups |
gmane.comp.java.objectweb.asm |
| Message-ID |
<[email protected]> |
This is a multi-part message in MIME format...
------------=_1668539074-2706-3
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
----- Original Message -----
> From: "sify21" <[email protected]>
> To: "asm" <[email protected]>
> Sent: Tuesday, November 15, 2022 7:33:38 PM
> Subject: [asm] [Question] How to map parameter annotations to correspondi=
ng parameters
> Hi all,
> As per the javadoc on `MethodVisitor.visitParameterAnnotation`, the
> `parameter` argument may not correspond to the index in the parameter
> descriptor, then how should I map parameter annotations and parameters
> correctly?
>=20
> At first I thought I cound use parameter access_flags from
> `MethodVisitor.visitParameter`, and ignore those formal parameters who are
> `ACC_SYNTHETIC` or `ACC_MANDATED`, then the remaining formal parameters a=
nd
> the parameter annotations would just match.
>=20
> But it turns out that `MethodParameters` attribute doesn't exist in clas=
sfile
> by default, I need to pass `-parameters` to javac to generate it, and
> `LocalVariableTable` doesn't have access_flags either. That means paramet=
er
> access_flags are not available in classfile, and I can't tell which param=
eter
> is synthetic in method descriptor.
>=20
> I'm also wondering how java reflection framework does the mapping.
Three solutions,
1) requires a parameter annotation that contains the name of the parameter.
2) force compilation using -parameters.
3) use a record as parameter, because you can reflect easily on the record =
components but it requires Java 17.
>=20
> I posted a similar question on stackoverflow, you can also give your advi=
ce
> there.
> https://stackoverflow.com/questions/74446059/how-to-map-parameter-annotat=
ions-to-corresponding-method-parameter-in-classfile
R=C3=A9mi
>=20
>=20
> --
> You receive this message as a subscriber of the [email protected] mailing list.
> To unsubscribe: mailto:[email protected]
> For general help: mailto:[email protected]?subject=3Dhelp
> OW2 mailing lists service home page: http://www.ow2.org/wws
------------=_1668539074-2706-3
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
--
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
------------=_1668539074-2706-3--