RFR: JDK-8322878: Including sealing information Class.toGenericString()

Joe Darcy darcy at openjdk.org
Wed Jan 3 18:12:47 UTC 2024


On Wed, 3 Jan 2024 14:52:48 GMT, Roger Riggs <rriggs 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.
>
> 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.

If Class.toGenericString() turned out to be performance sensitive, which would be a surprise, then we could look into alternate implementations.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17239#discussion_r1440757367


More information about the core-libs-dev mailing list