Are there any downsides if we add Enum.name() to the list of constant expressions in the JLS?
Kasper Nielsen
kasperni at gmail.com
Thu Oct 17 15:08:38 UTC 2024
Hi, I know this feature has been requested a number of times. But I want to
add one more usecase. There is common pattern in many frameworks of
specifying a factory class in an annotation a.la.
@SomeFrameworkAnnotation(factory = MyAppFactory.class)
Unfortunately, this pattern requires some more effort, if you want to use
it together with modules. Either you need to open the package or handoff a
Lookup object to the framework in some way. While this isn't super
complicated, it would ease the on-ramp if you could simply use
@SomeFrameworkAnnotation(factory = MyAppFactory::new)
I know this type of "annotation programming" aren't really used in the
JDK, but in Java's wider ecosystem I see it a lot.
Best, Kasper
> Idea: What about allowing lambda values for Class-valued annotation
> properties when the Class is a functional interface?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20241017/86ff5c87/attachment-0001.htm>
More information about the amber-dev
mailing list