> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Java Non-Sealed Interface

A `non-sealed` interface is a type declaration that explicitly opts out of the restricted inheritance hierarchy established by a parent `sealed` interface. By applying the `non-sealed` modifier, the interface re-opens the type hierarchy, allowing any arbitrary, unknown class or interface to implement or extend it without requiring explicit permission from the parent.

In Java's sealed classes architecture, any type permitted to extend or implement a `sealed` parent must explicitly declare its own sealing state to maintain hierarchy control. While classes have three modifier options (`sealed`, `non-sealed`, or `final`), interfaces inherently cannot be `final`. Therefore, an interface extending a `sealed` interface must be declared as either `sealed` or `non-sealed`.

```java theme={"dark"}
// The parent interface restricts its direct implementations
public sealed interface Shape permits Circle, Polygon {
    double calculateArea();
}

// A permitted class can be declared final to terminate the hierarchy
final class Circle implements Shape {
    public double calculateArea() { return 0.0; }
}

// A permitted interface cannot be final. 
// Using 'non-sealed' satisfies the compiler and re-opens this specific branch.
non-sealed interface Polygon extends Shape {
    int getNumberOfSides();
}

// Any unknown type can now extend or implement the non-sealed interface
interface IrregularPolygon extends Polygon {
    // Valid without needing permission from Polygon or Shape
}

class Hexagon implements Polygon {
    public double calculateArea() { return 0.0; }
    public int getNumberOfSides() { return 6; }
}
```

**Technical Characteristics:**

* **Hyphenated Contextual Keyword:** `non-sealed` is the first and only hyphenated keyword in the Java language. It is a contextual keyword, meaning it only functions as a reserved modifier when placed in the modifier list of a class or interface declaration.
* **Exhaustiveness Checking:** The presence of a `non-sealed` interface does not break exhaustiveness checking for pattern matching on the root `sealed` type. A `switch` expression on the parent `sealed` interface (e.g., `Shape`) remains fully exhaustive as long as all permitted direct subtypes (e.g., `case Circle c` and `case Polygon p`) are covered. A `default` clause is not required. Furthermore, when switching directly on the `non-sealed` type itself, exhaustiveness is achieved by providing an unconditional type pattern (e.g., `case Polygon p ->`), which also eliminates the need for a `default` keyword.
* **Asymmetric Transitivity:** The `non-sealed` modifier affects only its own descendants. It does not invalidate the sealing of its parent. The parent `sealed` interface remains strictly sealed and continues to reject direct implementations from unpermitted types, while the branch originating from the `non-sealed` interface becomes entirely open.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Java Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
