A sealed class/interface does not need to declare a permits
clause if all its subtypes are declared within the same file as the sealed type.
Sealed classes were recently stabilised in Java 17, and provide a way to control whether users can create new subclasses from a particular class. The Java Language Specification Section 8.1.1.2 mentions that a sealed class need not have a permits
clause if all direct child classes are placed in the same file.
// The permits clause isn't required!
sealed class Sealed permits Child1, Child2 {
// ...
}
final class Child1 extends Sealed {}
final class Child2 extends Sealed {}
Remove the permits clause.
sealed class Sealed {
// ...
}
final class Child1 extends Sealed {}
final class Child2 extends Sealed {}