On Tue, 16 Aug 2022 17:30:37 GMT, Joe Darcy <[email protected]> wrote:

>> Sorry, it looks like there is no way to access the synthetic/mandated 
>> information using the annotation processing API. Am I missing something?
>
>> Sorry, it looks like there is no way to access the synthetic/mandated 
>> information using the annotation processing API. Am I missing something?
> 
> For reasons of providing a minimal core language model that could be reused, 
> less essential functionality is split in the language model API to be 
> provided by an implementation of javax.lang.model.util.Elements.
> 
> So if you subclass JavacTestingAbstractProcessor files that test directory, 
> you could use
> 
> eltUtils.getOrigin(elementForParameter)
> 
> to see if an element is marked as javax.lang.model.util.Enum 
> Elements.Origin.{MANDATED, SYNTHETIC}.
> 
> Many of the annotation processing tests use a pattern of using a 
> runtime-retention annotation to encode what the expected answer is. In this 
> case, I'd recommend a method/constructor annotation to hold the expected 
> origin of the parameters.
> 
> (The annotation processing API does filter out some SYNTHETIC constructs, but 
> I don't recall if that is done at a parameter level.)
> 
> HTH

Thanks, I started working on a test, but the results are somewhat inconsistent 
(no implicit parameter is present for inner class ctors, no synthetic 
parameters for enum ctors, parameter of valueOf is MANDATED, implicit 
parameters in compact record ctor are MANDATED).
I'm not sure how we want to proceed with that or if there are known issues 
about that, but it might be better to tackle that separately. What do you think?

-------------

PR: https://git.openjdk.org/jdk/pull/9862

Reply via email to