Which version of Java finalized the sealed class feature?

The story behind the answer

Java 17 finalized the sealed class feature as a standard part of the Java language.

Sealed classes and interfaces let an API author explicitly restrict which classes may directly extend or implement a type. A declaration can use sealed together with a permits clause, while each permitted subclass must indicate whether it is final, sealed, or non-sealed. This makes the intended shape of a type hierarchy visible and enforceable.

The feature arrived through a staged preview process. JEP 360 introduced sealed classes as a preview feature targeted at JDK 15, and JEP 397 carried a revised second preview into JDK 16. After feedback and specification changes, JEP 409 delivered the finalized feature in Java 17, a long-term-support release.

Sealed classes are often confused with final classes. A final class permits no subclasses at all; a sealed class permits a fixed, named set. They also support stronger reasoning about exhaustive type handling, particularly alongside pattern matching and switch enhancements introduced in later Java releases. The JVM records permitted types in a PermittedSubclasses class-file attribute.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: