JDK-8225056 : VM support for sealed classes
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-05-30
  • Updated: 2024-10-10
  • Resolved: 2020-06-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b26Fixed
Related Reports
CSR :  
Description
The classfile for a sealed type must have a `PermittedSubtypes` attribute, which enumerates the permitted subtypes. 

PermittedSubtypes_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 permitted_subtypes_count;
    u2 classes[permitted_subtypes_count];
}

reject classloading of subtypes of sealed type if not on the list
allow subtyping of final classes if the subtype is allowed to extend the sealed class
other issues to consider:
- The use of `ACC_FINAL` + `PermittedSubtypes` as a way to mark a type sealed;
- The form of the `PermittedSubtypes` attribute
- The approach used to validate subtyping
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/843695160574 User: vromero Date: 2020-06-01 21:01:06 +0000
01-06-2020

The PermittedSubtypes attribute has been renamed to PermittedSubclasses.
07-05-2020

Amber checkins for VM support for sealed types: Changeset: 7880389d8172 Author: hseigel Date: 2019-07-23 18:36 -0400 URL: https://hg.openjdk.java.net/amber/amber/rev/7880389d8172 module checking for sealed types, disallow changing PermittedSubtypes attr, adding tests ! src/hotspot/share/classfile/classFileParser.cpp ! src/hotspot/share/classfile/classFileParser.hpp ! src/hotspot/share/oops/instanceKlass.cpp ! src/hotspot/share/oops/instanceKlass.hpp ! src/hotspot/share/prims/jvmti.xml ! src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp ! src/hotspot/share/prims/jvmtiClassFileReconstituter.hpp ! src/hotspot/share/prims/jvmtiRedefineClasses.cpp ! src/java.instrument/share/native/libinstrument/JavaExceptions.c + test/hotspot/jtreg/runtime/modules/SealedModuleTest.java + test/hotspot/jtreg/runtime/modules/sealedP1/c1.java + test/hotspot/jtreg/runtime/modules/sealedP1/superClass.java + test/hotspot/jtreg/runtime/modules/sealedP2/c2.java + test/hotspot/jtreg/runtime/modules/sealedP3/c3.java + test/hotspot/jtreg/runtime/sealedTypes/Pkg/Permitted.java + test/hotspot/jtreg/runtime/sealedTypes/Pkg/notPermitted.jcod + test/hotspot/jtreg/runtime/sealedTypes/Pkg/sealedInterface.java + test/hotspot/jtreg/runtime/sealedTypes/SealedUnnamedModuleIntfTest.java + test/hotspot/jtreg/runtime/sealedTypes/SealedUnnamedModuleTest.java + test/hotspot/jtreg/runtime/sealedTypes/asteroids/Pluto.java + test/hotspot/jtreg/runtime/sealedTypes/otherPkg/wrongPackage.java + test/hotspot/jtreg/runtime/sealedTypes/planets/Mars.jcod + test/hotspot/jtreg/runtime/sealedTypes/planets/Neptune.java + test/hotspot/jtreg/runtime/sealedTypes/planets/outerPlanets.java + test/hotspot/jtreg/runtime/sealedTypes/sealedTest.java + test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefinePermittedSubtypes.java Changeset: 6ef931c06a1a Author: vromero Date: 2019-07-29 18:02 -0400 URL: https://hg.openjdk.java.net/amber/amber/rev/6ef931c06a1a make JVM_GetPermittedSubtypes return an array of Strings ! src/hotspot/share/classfile/classFileParser.cpp ! src/hotspot/share/prims/jvm.cpp ! src/java.base/share/classes/java/lang/Class.java ! src/java.base/share/native/libjava/Class.c + test/hotspot/jtreg/runtime/sealedTypes/abstractSealedTest.java + test/hotspot/jtreg/runtime/sealedTypes/getPermittedSubtypesTest.java + test/hotspot/jtreg/runtime/sealedTypes/noLoadSubtypes.jcod + test/hotspot/jtreg/runtime/sealedTypes/overrideSealedTest.java
30-07-2019