Annotation discovery JEP

David Lloyd david.lloyd at redhat.com
Fri Dec 1 17:01:06 UTC 2017


On Fri, Dec 1, 2017 at 10:14 AM, Greg Wilkins <gregw at webtide.com> wrote:
>
> David,
>
> I've seen such discussions.  Perhaps that could have been done if it was
> added from day 0, but there are already
> modules in the wild with annotations that need to be scanned which will not
> have any index.
>
> So I think we are going to need to support full discovery at runtime with
> any metadata indexes just being optional optimisations rather that required
> element.

I'm in favor by principle, but I think as a practical matter, this
just won't work.  We tried this with Jandex and the result was
impractical: people have @Deprecated and @FunctionalInterface and so
forth all over the place.  The resulting indexes are huge and we go to
great pains to keep them compact.  I don't think there's any practical
platform-level solution that doesn't involve some form of opt-in.

That said, I think your fears could be mitigated by the fact that any
software which would use the new API to find annotations would also
usually be in a position to update their published annotations with
@Indexed; and also, there could be a command-line solution as well
(for example, an option could be added to javac to explicitly add
indexes for certain unannotated annotations) for the last case.

> We also need to have a bit of a review of the discoverable annotations that
> exist to determine if it really is known at compile time which ones need to
> be discoverable.  Are there any use-cases for discovering arbitrary
> annotations? etc.

That I do not know.

-- 
- DML


More information about the discuss mailing list