JEP 301: Enhanced Enums
Reinier Zwitserloot
reinier at zwitserloot.com
Thu Apr 16 20:32:59 UTC 2020
I'm not sure if this mailing list is still alive, or for that matter, if
JEP301 is still alive.
A quick note on JEP301: The syntax proposal in the JEP[1] is as follows:
enum Argument<X> {
STRING<String>(String.class);
}
One alternative concern that comes up: The same concern that was addressed
by this java language change:
class Example {
public void foo(Example this) {}
}
As I understand it, the point is to allow annotating the receiver. In that
vein, it would be consistent if you can do the same with enum constants.
The syntax would then presumably be:
enum Argument<X> {
Argument<String> STRING(String.class);
}
in other words, you can put the type of the 'field' in front, but that is
optional. It obviously wouldn't be if generics are involved, but one thing
is not related to the other. This would be legal:
enum Rank {
Rank HEARTS,
CLUBS,
com.foo. at SomeAnnotation Rank SPADES
}
I have no real contributions on the topic of how useful such a feature
would be. Merely pointing out that the `void foo(SelfType this)` feature
exists.
[1] https://openjdk.java.net/jeps/301
--Reinier Zwitserloot
More information about the platform-jep-discuss
mailing list