Are there any downsides if we add Enum.name() to the list of constant expressions in the JLS?

Brian Goetz brian.goetz at oracle.com
Thu Oct 17 16:01:26 UTC 2024


Yes, this is a frequent request. And our analysis of this remains: it is 
reasonable from a linguistic point of view, but the implementation is 
hellaciously intrusive (as it cuts through all the layers mentioned), 
and so ends up having a relatively poor return-on-investment compared to 
other improvements.


On 10/17/2024 11:08 AM, Kasper Nielsen wrote:
> 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 
> <http://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/0e436b09/attachment.htm>


More information about the amber-dev mailing list