Quick revision
The short answer
Java forced super(...) first so that a superclass always sees itself fully initialised before any subclass code runs, which protects the integrity of every object. That rule also blocked harmless code such as validating an argument, pushing people into static helper workarounds. JEP 513, final in Java 25, keeps the safety goal by forbidding any use of this in the new prologue before the constructor call, while allowing other statements and assignments to the class's own fields; it is also groundwork for value classes, whose fields must be set before super. The lesson for judging future changes is to ask whether a change keeps the original invariant while removing workarounds, and to adopt it when our target release allows.
What to remember
In this answer, we saw that Java required super(...) first so that superclass state is always initialised before subclass code can observe the object, an invariant the bytecode verifier also enforces. The rule was stricter than needed, blocking harmless argument validation and forcing static helpers. JEP 513, final in Java 25, adds a prologue that may run ordinary code and assign the class's own fields but may not use this otherwise, keeping the invariant while removing the workarounds, and laying groundwork for value classes. The general lesson is to judge a language change by whether it keeps the original safety goal while removing workarounds, and to adopt it when our target release supports it as a final feature.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Java forced super(...) first so that a superclass always sees itself fully initialised before any subclass code runs, which protects the integrity of every object. That rule also blocked harmless code such as validating an argument, pushing people into static helper workarounds. JEP 513, final in Java 25, keeps the safety goal by forbidding any use of this in the new prologue before the constructor call, while allowing other statements and assignments to the class's own fields; it is also groundwork for value classes, whose fields must be set before super. The lesson for judging future changes is to ask whether a change keeps the original invariant while removing workarounds, and to adopt it when our target release allows.
Background to this question
Language rules that seem arbitrary usually protect something, and senior engineers are expected to know what. This question uses one rule, super first, to test three things: whether we understand the safety property behind it, whether we can explain why relaxing it now is safe, and whether we can turn that into a way of judging language changes for an organisation. In this answer, we will recap how object construction works, explain the invariant behind the rule, look at the cost it imposed, see exactly what JEP 513 allows and forbids and how it connects to value classes, and derive a practical way to evaluate future language features.
1A Quick Recap: Construction Runs From the Top Down
When we create an object of class C that extends B that extends A, the JVM allocates the memory once, with every field set to its default value, zero or null. Then constructors run in a chain: C's constructor calls B's, B's calls A's, A's calls Object's. The bodies then complete from the top down: Object, A, B, C.
So at any moment during construction, the object is partly built. Fields declared in classes whose constructors have finished are initialised; fields in classes further down are still at their defaults.
2The Invariant Behind super(...) First
The rule that super(...) or this(...) must be the first statement guarantees one thing: no code of a subclass can run on the object before its superclass has finished initialising its own part. A superclass author can write a constructor knowing that nobody can observe or modify the superclass state before that constructor completes, and that every method of the superclass runs on a fully initialised superclass part.
This protects the integrity of objects in a language where classes are often written by different people. A class like java.io.FileInputStream or a security-sensitive class can rely on its own initialisation having happened before any subclass code touches the object. The JVM's bytecode verifier enforces the same idea: until the super constructor call, the new object is marked as uninitialised and cannot be used as a normal reference.
- Allocate object, fields at defaultsdone by new before any constructor runs
- First statement: super(...) or this(...)nothing may come before it
- Superclass constructors completeparent state is fully initialised
- Subclass field initialisers runthen the rest of the constructor body
4 steps in order. Play them, or step through them one at a time.
3What the Rule Cost Us
The rule was stricter than the invariant needed. It banned not only code that touches the object, but any code at all, including code that only looks at the arguments. Validating an argument before passing it to super, or computing a value once and passing it to two parameters, was impossible without workarounds.
Developers wrote static helpers, extra private constructors or factory methods just to run one if statement first. None of these made programs safer; they only made them longer. That gap between what the rule protected and what it forbade is what made it a good candidate for change.
4What JEP 513 Allows, and What It Still Forbids
JEP 513, flexible constructor bodies, was previewed in Java 22 to 24 and finalised in Java 25. It splits a constructor into a prologue, the statements before the explicit this(...) or super(...) call, and an epilogue, the statements after it. The prologue may contain ordinary code that does not use the object under construction.
The key design decision is that the prologue cannot use this, except to assign fields of the class being constructed that have no initialiser. So no code can still read the half-built object or call an overridable method on it before the superclass is initialised, and the original invariant holds. What changed is that harmless code, which never touched the object, is no longer forbidden.
The field assignments are the interesting part. They let a subclass set its own fields before the superclass constructor runs. That fixes an old trap: if a superclass constructor calls an overridable method, the subclass override used to see its fields still at their defaults. With fields assigned in the prologue, the override sees the real values.
5Groundwork for Value Classes
JEP 513 is also a step towards Project Valhalla's value classes. A value class has no object identity, and its fields must be fully set before the object can be observed at all, including by superclass constructor code; there is no moment where a half-initialised value object may exist. The ability to assign fields before calling super is exactly what such classes need. Value classes are not part of Java 25, so check the current status, but the language is being prepared so that the same constructor rules will work for both kinds of class.
6How to Judge Future Language Changes
This history suggests a useful test for new features. First, identify the invariant the old rule protected, and check whether the new feature keeps it. JEP 513 keeps the guarantee that superclass state is initialised before it can be observed, so the safety argument is intact. Second, look at the workarounds the old rule forced, and ask whether the change removes them; here, static helpers and extra factories can go. Third, see whether the change fits a longer direction, such as value classes, which tells us it is unlikely to be reversed.
Then adoption is a practical decision. A finalised feature in an LTS release, such as JEP 513 in Java 25, is safe to use once the code base targets that release; libraries that must support Java 17 or 21 cannot use it yet. Preview features are for experiments only, because they need --enable-preview and can change. And as with any feature, we use it where it makes code clearer, not everywhere at once.
7Follow-up questions
Why did it take until Java 25 to relax the rule?
Because the rule is enforced at two levels, the language and the JVM's bytecode verifier, and the change had to be designed so the verifier's safety guarantee still holds. It also went through three preview rounds, in Java 22 to 24, to refine what the prologue may contain, notably the field assignments added during previews.
Does JEP 513 change the order in which constructors run?
No. Superclass constructors still finish before the subclass's epilogue runs, and field initialisers still run right after the super call. The only change is that some code can now run before the call, and it cannot observe the object.
Should we rewrite existing static helper workarounds?
Not as a project. When we touch a class for another reason and the code base targets Java 25, moving a validation into the prologue is a small readability improvement. There is no correctness gain in rewriting working code.
8Conclusion
In this answer, we saw that Java required super(...) first so that superclass state is always initialised before subclass code can observe the object, an invariant the bytecode verifier also enforces. The rule was stricter than needed, blocking harmless argument validation and forcing static helpers. JEP 513, final in Java 25, adds a prologue that may run ordinary code and assign the class's own fields but may not use this otherwise, keeping the invariant while removing the workarounds, and laying groundwork for value classes. The general lesson is to judge a language change by whether it keeps the original safety goal while removing workarounds, and to adopt it when our target release supports it as a final feature.
Open with
The super-first rule existed to protect an invariant: a superclass is fully initialised before any subclass code can see or touch the object. Construction runs constructors from the top of the hierarchy down, and if subclass code could run first, it could observe or corrupt parent state, or call methods on a half-built object.
Then, if they want more
The verifier enforces the same idea at the bytecode level. The trouble was that the rule was broader than the invariant. It banned any statement before super, even code that only checks an argument, so people wrote static helpers or extra factories just to run an if statement.
JEP 513, finalised in Java 25 after three previews, fixes that precisely: statements before super are allowed as long as they don't use this, with one exception, you can assign your own class's fields.
So the safety guarantee is unchanged, while the workarounds go away, and those early field assignments are also groundwork for value classes, which need all fields set before the object can be observed.
For me the lesson in judging language changes is: find the invariant the old rule protected, check the change keeps it, see which workarounds it removes and whether it fits a longer direction. Then adopt it when our target release has it as a final feature, not while it's in preview.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 25, Java 22, Java 17
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Java constructors always run the full superclass chain and, until Java 25, forced...": https://scrivio-interview-library.netlify.app/java/classes-and-objects/d4016df8bf/