-
Type:
CSR
-
Resolution: Approved
-
Priority:
P4
-
Component/s: core-libs
-
None
-
behavioral
-
minimal
-
Relying on exact textual output of toString-like methods is brittle.
-
Java API
-
SE
Summary
Include sealed/non-sealed conceptual modifiers in the output of Class.toGenericString().
Problem
While appearing as a modifier in Java source, neither sealed nor non-sealed is not included in the output of Class.toGenericString(), which tends to include more information than Class.toString().
Solution
Update the specification and implementation of Class.toGenericString() to include sealed/non-sealed information for a class or interface.
Consistent with omitted implements and extends information, the list of permitted classes/interfaces is omitted by Class.toGenericString().
Specification
--- a/src/java.base/share/classes/java/lang/Class.java
+++ b/src/java.base/share/classes/java/lang/Class.java
@@ -261,7 +261,8 @@ public String toString() {
/**
* Returns a string describing this {@code Class}, including
- * information about modifiers and type parameters.
+ * information about modifiers, {@link #isSealed() sealed}/{@code
+ * non-sealed} status, and type parameters.
*
* The string is formatted as a list of type modifiers, if any,
* followed by the kind of type (empty string for primitive types
- csr of
-
JDK-8322878 Including sealing information Class.toGenericString()
-
- Resolved
-