RFR: JDK-8322878: Including sealing information Class.toGenericString()
Roger Riggs
rriggs at openjdk.org
Wed Jan 3 15:02:39 UTC 2024
On Wed, 3 Jan 2024 06:43:22 GMT, Joe Darcy <darcy at openjdk.org> wrote:
> As recently discussed on core libs, sealed-ness information could be included in the Class.toGenericString() output, analagous to how "modifiers" that also correspond to JVM access flags are handled.
>
> This is the initial spec, implementation, and test updated needed for that change. If there is consensus this is a reasonable direction, I'll create the CSR, etc.
LGTM
src/java.base/share/classes/java/lang/Class.java line 264:
> 262: /**
> 263: * Returns a string describing this {@code Class}, including
> 264: * information about modifiers, {@linkplain #isSealed() sealing}, and type parameters.
If Class.toGenericString is a useful API point for describing the blessed order of modifiers in the JDK
perhaps the existing classes that describe modifiers could/should cross reference this method.
src/java.base/share/classes/java/lang/Class.java line 320:
> 318: // sufficient to check for sealed-ness after all
> 319: // modifiers are printed.
> 320: boolean isSealed = isSealed();
A small concern about performance.
Class.isSealed() calls getPermittedSubclasses() which assembles and filters the list of classes and a possible security manager check and then only checks for non-null.
Perhaps a separate issue could look at that.
-------------
Marked as reviewed by rriggs (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17239#pullrequestreview-1802318323
PR Review Comment: https://git.openjdk.org/jdk/pull/17239#discussion_r1440551717
PR Review Comment: https://git.openjdk.org/jdk/pull/17239#discussion_r1440543767
More information about the core-libs-dev
mailing list