JEP proposed to target JDK 25: 513: Flexible Constructor Bodies
Mark Reinhold
mark.reinhold at oracle.com
Tue Apr 29 20:41:35 UTC 2025
The following JEP is proposed to target JDK 25:
513: Flexible Constructor Bodies
https://openjdk.org/jeps/513
Summary: In the body of a constructor, allow statements to appear
before an explicit constructor invocation, i.e., super(...) or
this(...). Such statements cannot reference the object under
construction, but they can initialize its fields and perform other safe
computations. This change allows many constructors to be expressed
more naturally. It also allows fields to be initialized before they
become visible to other code in the class, such as methods called from
a superclass constructor, thereby improving safety.
Feedback on this proposal from JDK Project Committers and Reviewers [1]
is more than welcome, as are reasoned objections. If no such objections
are raised by 21:00 UTC on Tuesday, 6 May, or if they’re raised and
then satisfactorily answered, then per the JEP 2.0 process proposal [2]
I’ll target this JEP to JDK 25.
- Mark
[1] https://openjdk.org/census#jdk
[2] https://cr.openjdk.java.net/~mr/jep/jep-2.0-02.html
More information about the jdk-dev
mailing list