Inheritance tutorial - Polymorphism article ( https://dev.java/learn/inheritance/polymorphism/ ) is out of date as of Java 25 with "JEP 513: Flexible Constructor Bodies" ( https://openjdk.org/jeps/513 ) · Issue #232 · java/devjava-content · GitHub
Skip to content

Inheritance tutorial - Polymorphism article ( https://dev.java/learn/inheritance/polymorphism/ ) is out of date as of Java 25 with "JEP 513: Flexible Constructor Bodies" ( https://openjdk.org/jeps/513 ) #232

@willy-b

Description

@willy-b

In the latest version of the Inheritance tutorial - Polymorphism article at https://dev.java/learn/inheritance/polymorphism/ (archived as is at https://web.archive.org/web/20260424021350/https://dev.java/learn/inheritance/polymorphism/ ),
it is stated

Invocation of a superclass constructor must be the first line in the subclass constructor.

Which has been true, but is now out of date as of Java 25 with the release of "JEP 513: Flexible Constructor Bodies" ( https://openjdk.org/jeps/513 ).

Per JEP 513:

Status Closed / Delivered
Release 25
[...]
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.

See also https://docs.oracle.com/en/java/javase/25/language/flexible-constructor-bodies.html .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions