-
Bug
-
Resolution: Fixed
-
P3
-
repo-valhalla
In JEP 401, Number should be migrated to an abstract value class together with Record. However, user-defined value class like in this attached One.java, which is the most simple implementation implementing 4 abstract methods, cannot extend Number, with the error message like:
$ $valhalla/bin/javac --enable-preview --release 23 One.java
One.java:1: error: The identity type Number cannot be a supertype of the value type One
value class One extends Number {
^
Note: One.java uses preview features of Java SE 23.
Note: Recompile with -Xlint:preview for details.
This error does not happen with user-defined final value classes extending user-defined abstract value classes, or user-defined value records.
This is originally showcased by Ethan McCue attending JVMLS 2024, first reproduced with the source code launcher.
Note: Number has been migrated to an abstract value class, there was a bug and the compiler was setting both the value and the identity flag to migrated value classes. This was the reason of the issue
$ $valhalla/bin/javac --enable-preview --release 23 One.java
One.java:1: error: The identity type Number cannot be a supertype of the value type One
value class One extends Number {
^
Note: One.java uses preview features of Java SE 23.
Note: Recompile with -Xlint:preview for details.
This error does not happen with user-defined final value classes extending user-defined abstract value classes, or user-defined value records.
This is originally showcased by Ethan McCue attending JVMLS 2024, first reproduced with the source code launcher.
Note: Number has been migrated to an abstract value class, there was a bug and the compiler was setting both the value and the identity flag to migrated value classes. This was the reason of the issue
- links to
-
Commit(lworld) openjdk/valhalla/cbf3b7ad
-
Review(lworld) openjdk/valhalla/1195