New candidate JEP: 513: Flexible Constructor Bodies

Mark Reinhold mark.reinhold at oracle.com
Tue Apr 22 12:02:27 UTC 2025


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.

- Mark


More information about the jdk-dev mailing list