2 questions about enums and the closed/withdrawn JEP 301

David Alayachew davidalayachew at gmail.com
Wed Mar 29 14:10:30 UTC 2023


Hello RedIODev,

Thank you for your response!

> I think if we are talking about the initial
> question again the elephant in the room
> is the lack of a way to express subtypes
> in supertypes (F-bounds) without using
> "hacks" like the recursive generic. That
> this (mis)use of generics is confusing is
> demonstrated in this thread and in many
> others.

Just to give some context here, I am a junior java developer. Generics is
something I've only recently gotten comfortable with. And most of my
understanding is rooted in "if I see this specific thing between the angle
brackets, I do another specific thing to satisfy the compiler." That is
about as far as my concrete understanding went until yesterday.

I say all that to say, I couldn't begin to have a sense of right/wrong,
confusing/intuitive, or mis/use at this level of comprehension. I
understand generics well enough, and I knew that Enums had that recursive
self reference. I was initially surprised when seeing it, but I have
emulated it to useful effect many times over.

My confusion was in trying to understand the discussion. I had a
semi-decent grasp of generics as a concept, but not its terminology or why
specific rules were in play (and stopping JEP 301). It's like an elementary
student who understands how to manipulate fractions, but never
learned/remembered the exact terms like numerator/denominator is, or why
divide by zero is wrong, only that it shouldn't be done. I only know how to
solve the problem, but not its deeper intricacies.

> A good solution would be to introduce a
> "This" type that always refers to the
> current class type even when inheriting.
> I'm by far not the first person to suggest
> that.
>
> But the bigger problem is that this ship
> has sailed for the Enum class. Even if the
> This type was introduced now and used
> in Enum removing the generic parameter
> would be a braking change to the Enum
> class braking every code that relies on
> the parameter to be present.
>
> The possibility to add This regardless of
> the Enum class should still be considered
> thought.

Well, I certainly see the utility. It certainly is a lot easier to grasp
from a distance.

But is the only reason why we are doing this is because the existing
methodology is confusing and easy to trip up on? Or does it allow us to do
stuff we couldn't before?

Thank you for your help and insight!
David Alayachew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230329/66c8953c/attachment.htm>


More information about the amber-dev mailing list