Question regarding type use annotation on method parameter type
Laird Nelson
ljnelson at gmail.com
Thu Feb 16 01:59:19 UTC 2023
On Wed, Feb 15, 2023 at 5:07 PM Alex Buckley <alex.buckley at oracle.com>
wrote:
> Via ExecutableElement::getParameters, the VariableElement which
> represents the declaration of formal parameter `s` should expose a
> TypeMirror for the type `@A String`.
>
Thank you. That is exactly what I expected. It does not. Should I file a
bug?
Test code excerpted below:
Element e = elements.getTypeElement("B");
ExecutableElement c = (ExecutableElement)e.getEnclosedElements().get(1); //
0 is the implicit constructor; 1 is the c method
assert "c".equals(c.getSimpleName().toString()); // yep, got the right
method
VariableElement s = (VariableElement)c.getParameters().get(0);
assert "s".equals(s.getSimpleName().toString()); // yep, got the right
parameter
DeclaredType sAsType = (DeclaredType)s.asType();
assert !sAsType.getAnnotations().isEmpty(); // fails; it is empty
Thanks,
Laird
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20230215/5a8a4e8a/attachment.htm>
More information about the compiler-dev
mailing list