Annotation discovery JEP

Greg Wilkins gregw at webtide.com
Fri Dec 1 17:46:43 UTC 2017


David,

I hear you that the indexes may be large.   But currently many containers
have to generate these large indexes on the fly so they can find and
satisfy annotations that register interest in other annotations (eg
@HandleTypes).   The alternative to large dynamic indexes is doing multiple
scans, which can take a long long time (it's amazing how many jars can be
put into one war!).

I think the primary goal of this API should be correctness - ie to produce
exactly the right list of classes, even if it takes a long time using lots
of memory and/or time.
Regardless of implementation, I think this effort would be useful if all it
produced was a specification document that clearly stated what classes
should be discovered and scanned, because currently it is entirely not
clear what classes are resolved when you consider class paths, modules
paths, upgrade paths, multi release jars, etc.

It is a secondary goal to come up with mechanism like meta-inf indexes that
will make it work both correctly AND efficiently.

cheers






On 1 December 2017 at 18:01, David Lloyd <david.lloyd at redhat.com> wrote:

> 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
>



-- 
Greg Wilkins <gregw at webtide.com> CTO http://webtide.com


More information about the discuss mailing list