openclover / clover

This repository contains source code of OpenClover Core as well as its integrations: Clover-for-Ant, Clover-for-Eclipse and Clover-for-IDEA plugins. Sources are licensed under Apache 2.0 license.
Other
57 stars 14 forks source link

Support Java 17 sealed types #215

Closed marek-parfianowicz closed 8 months ago

marek-parfianowicz commented 8 months ago

Sealed types was a preview feature in Java 15. It became part of the language in Java 17.

Sealed types is a feature introduced in Java to enhance the control and security of class access and inheritance.

Example:

public sealed class Shape permits Circle, Triangle {
    // ...
}

A permitted subclass may be declared non-sealed, then it is open for extension.

public non-sealed class Shape permits Circle, Triangle {
    // ...
}

A sealed class imposes three important constraints on its permitted subclasses:

All permitted subclasses must belong to the same module as the sealed class.
Every permitted subclass must explicitly extend the sealed class.
Every permitted subclass must define a modifier: final, sealed, or non-sealed.

Can be used for classes and interfaces. But not for record classes or enums?

To be implemented: