Preview features and class file formats
Remi Forax
forax at univ-mlv.fr
Tue Apr 22 09:12:00 UTC 2025
----- Original Message -----
> From: "Alex Buckley" <alex.buckley at oracle.com>
> To: "Chen Liang" <chen.l.liang at oracle.com>, "valhalla-dev" <valhalla-dev at openjdk.org>, "compiler-dev"
> <compiler-dev at openjdk.org>
> Sent: Monday, April 21, 2025 11:21:54 PM
> Subject: Re: Preview features and class file formats
[...]
>
> For example, when records were previewing in Java 14, a framework that
> recognized a user class as a record (via Class::isRecord, which today
> we'd call a reflective preview API) could deserialize it more
> efficiently than normal classes, since records can't self-reference.
??
A record can reference itself,
public class RecordSelfReference {
record A(A a) {
A {
a = this;
}
}
public static void main(String[] args) {
var a = new A(null);
System.out.println(a);
}
}
It's useless because toString(), equals() and hashCode() go into an infinite loop, but you can.
>
> Alex
Rémi
More information about the compiler-dev
mailing list