You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an annotation processor queries the Element.getEnclosedElements() and generates results that implicitly depends on the order of the elements, then the processor will not be reinvoked when the enclosed element order is changed. As an example:
publicclassSubject {
publicinta;
publicintb;
}
The processor may generate a resource with the following contents
a[...]
b[...]
If the developer decides to only change up the order of the elements as:
publicclassSubject {
publicintb;
publicinta;
}
Then the processor would generate:
b[...]
a[...]
However, the processor is not reinvoked by the incremental compiler task.
This is a bug.
Workaround
Perform a clean build or the processor shouldn't depend on the element order. Alphabetic sorting may be a good solution.
Solution
Track the behaviour of the processors and the expected indexes for the associated elements. If the indexes change, reinvoke the processors.
We might consider adding a flag to the processor configuration to signal that a given processor actually depends on the element order. As most processors probably don't, tracking them could introduce some overhead.
Another note that is that we might get away by only tracking the relative order between elements that were reported as input dependencies to a given resource generation. This should be much easier to implement and more straight forward from a Processor perspective.
The text was updated successfully, but these errors were encountered:
If an annotation processor queries the
Element.getEnclosedElements()
and generates results that implicitly depends on the order of the elements, then the processor will not be reinvoked when the enclosed element order is changed. As an example:The processor may generate a resource with the following contents
If the developer decides to only change up the order of the elements as:
Then the processor would generate:
However, the processor is not reinvoked by the incremental compiler task.
This is a bug.
Workaround
Perform a clean build or the processor shouldn't depend on the element order. Alphabetic sorting may be a good solution.
Solution
Track the behaviour of the processors and the expected indexes for the associated elements. If the indexes change, reinvoke the processors.
We might consider adding a flag to the processor configuration to signal that a given processor actually depends on the element order. As most processors probably don't, tracking them could introduce some overhead.
Another note that is that we might get away by only tracking the relative order between elements that were reported as input dependencies to a given resource generation. This should be much easier to implement and more straight forward from a
Processor
perspective.The text was updated successfully, but these errors were encountered: