CKTIS / Java
The keyword non-sealed
The keyword non-sealed: The non-sealed modifier reopens a class or interface that is a direct permitted subtype of a sealed type.
Version: Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Syntax
non-sealedThe non-sealed modifier reopens a class or interface that is a direct permitted subtype of a sealed type.
Use it when a closed hierarchy intentionally delegates one extension point to unrestricted downstream implementations.
non-sealed is legal only with a direct sealed supertype and cannot be combined with final or sealed.
Subtypes of a non-sealed class may be ordinary, abstract, or final and need not appear in the original type’s permits clause.
Triangle prints shape=Triangle and sealed-child=false proves the branch is reopened.
Examples
public class Main { sealed interface Shape permits OpenShape {} non-sealed interface OpenShape extends Shape {} static final class Triangle implements OpenShape {} public static void main(String[] a){Shape s=new Triangle();System.out.println("shape="+s.getClass().getSimpleName());System.out.println("sealed-child="+OpenShape.class.isSealed());} }Result
shape=Triangle sealed-child=false
Triangle prints shape=Triangle and sealed-child=false proves the branch is reopened.