Java Annotation Processor, Processing Order -
i'm wondering if there way process annotations top down in class, or @ least in deterministic order.
it doesn't seem case because processor class provides:
boolean process(set<? extends typeelement> annotations, roundenvironment roundenv);
where roundenvironment allows access set
of annotated elements, e.g.:
set<? extends element> getelementsannotatedwith(typeelement a)
everything in terms of unordered collections, , makes order of processing unpredictable. there anyway around this, besides trying sort manually element name or something?
as have discovered, there not way force processing of annotations in specified order, using current interfaces.
here workaround. suppose wish process every declaration annotation, such annotations on fields , methods. don't register callback declarations. instead, invoke annotation processor every class. annotation processor obtains ast javac, walks in order prefer. example, checker framework uses implementation strategy.
this workaround might not sufficient needs, because still processes each class in arbitrary order -- instance, 1 depends on javac's staged compilation model.
Comments
Post a Comment