2 questions about enums and the closed/withdrawn JEP 301

Tesla Zhang ice1000kotlin at foxmail.com
Wed Mar 29 01:33:41 UTC 2023


Hi David,



I'm not an expert, but I'd like to share my understanding.


F-bound is a way of having access to the subtype in the supertype. That's a trick used by Java in the Enum interface, note that it has a generic parameter. If you have an enum T, then T extends Enum<T>. Note that this extends relation has some sort of recursion -- that's the F-bound.


A well-formed type is a type that makes sense. You can think of it as a type expression that doesn't contain an error. But you need to make sure you have a sensible criterion of "no error".





Regards,
Tesla

---Original---
From: "David Alayachew"<davidalayachew at gmail.com>
Date: Tue, Mar 28, 2023 19:46 PM
To: "amber-dev"<amber-dev at openjdk.org>;
Subject: 2 questions about enums and the closed/withdrawn JEP 301


Hello Amber Dev Team,

I was reading about JEP 301 and it's unfortunate withdrawal [1]. I also took a look at the linked bugs.openjdk.org link [2]. There, Maurizio Cimadamore linked to some discussions on the spec experts group of this team, explaining why they decided to withdraw efforts on this JEP for the time being.


Looking at 2 of the linked mailing list threads [3] [4] (and their subsequent links), I tried my best to understand what exactly was being explained, but failed to make sense of it. Here is the best that I could make of it.


It seems like the original attempt failed because trying to put generics on Enums immediately caused issues with some of thetools that use enums - specifically, EnumSet and EnumMap. It seems to have something to do with raw types not playing well with these specialized collections. Maurizio explained the why of this, but my brain struggled to understand a lot of the terminology. I tried googling, but ended up with a lot more concepts that I struggled to understand. Repeat for a few hours before I got tired out.


Key phrases that I struggled to understand from the original discussion in [3] were f-bound and well formed types. Googling the definitions to these terms felt like trying to learn integrals without knowing of derivatives or limits.


Moving on the next discussion in [4], it seems like the issue with raw types had been resolved by picking and choosing where we wanted to apply that logic, implying that that could be controlled by the JVM or something. Again, struggled to understand what was being said, but what I could pick up on was that they had found a solution, and just wanted to know if the cost of it/the effort needed to implement it was worth the benefit.


All of this leads me to 2 questions.


1. Could someone help me understand some of the more confusing terminology so that I can understand what is being said in those discussions?


2. (And perhaps this is answered already once I understand 1) What was the reason that enums weren't designed yo be generic in the first place? Did the designers avoid it because they felt it would be a bad fit?


Thank you all for your time and patience!
David Alayachew


[1] = https://openjdk.org/jeps/301
[2] = https://bugs.openjdk.org/browse/JDK-8170351
[3] = https://mail.openjdk.org/pipermail/amber-spec-experts/2017-May/000041.html
[4] = https://mail.openjdk.org/pipermail/amber-spec-experts/2018-December/000876.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230328/59fa5843/attachment-0001.htm>


More information about the amber-dev mailing list