JDK-8283540 : Update java.lang.invoke.VarHandle to use sealed classes
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Priority: P4
  • Status: Draft
  • Resolution: Unresolved
  • Fix Versions: 19
  • Submitted: 2022-03-23
  • Updated: 2022-03-26
Related Reports
CSR :  
Description
Summary
-------

Update `java.lang.invoke.VarHandle` as a sealed class

Problem
-------

As specified in the class specification, `VarHandle`s cannot be subclassed by users.   It does not have public constructor.

Solution
--------

Make `java.lang.invoke.VarHandle` a sealed class.

Specification
-------------

```
-public abstract class VarHandle implements Constable {
+public abstract sealed class VarHandle implements Constable
```

All permitted classes are package-private and not listed in the above specification change.   The javadoc of VarHandle shows that it's a public abstract sealed class without the permits clause.