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

David Alayachew davidalayachew at gmail.com
Fri Oct 18 02:48:10 UTC 2024


Thank you for your response Brian. Very informative, I appreciate it. You
definitely read my intent.

I now agree, keeping the border where it is makes the most sense. There are
other ways to achieve what I want, so I will go with those for now. And
like you mentioned, feasability aside, this will wreck people's mental
model. Cutting it short makes things significantly easier and cleaner.

And thank you for your response Archie. I was more speaking to annotations
that only support String values. The vast majority of annotations seem to
fall under that case, including the one I want to work with. I understand
that it is not the strongest argument, which is why I just wanted to see
the downsides of the idea.

As for your idea, I quite like it. No idea about the viability though.

On Thu, Oct 17, 2024, 12:01 PM Brian Goetz <brian.goetz at oracle.com> wrote:

> 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.
>
>  @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/9503f433/attachment-0001.htm>


More information about the amber-dev mailing list