Summary
-------
Update `java.lang.invoke.CallSite` as a sealed class and its direct subclasses, `ConstantCallSite`, `VolatileCallSite`, and `MutableCallSite` as non-sealed classes.
Problem
-------
`java.lang.invoke.CallSite` is not intended to be directly subclassed as it is currently specified in the class specification.
Solution
--------
Make `CallSite` as a sealed class and its direct subclasses `ConstantCallSite`, `VolatileCallSite`, and `MutableCallSite` are non-sealed as they are extendable by design.
Specification
-------------
```
diff --git a/src/java.base/share/classes/java/lang/invoke/CallSite.java b/src/java.base/share/classes/java/lang/invoke/CallSite.java
index e159e235f30..172d33f65b6 100644
--- a/src/java.base/share/classes/java/lang/invoke/CallSite.java
+++ b/src/java.base/share/classes/java/lang/invoke/CallSite.java
@@ -40,9 +40,9 @@ import jdk.internal.vm.annotation.Stable;
* In any case, it may be invoked through an associated method handle
* called its {@linkplain #dynamicInvoker dynamic invoker}.
* <p>
- * {@code CallSite} is an abstract class which does not allow
+ * {@code CallSite} is an abstract sealed class which does not allow
* direct subclassing by users. It has three immediate,
- * concrete subclasses that may be either instantiated or subclassed.
+ * concrete non-sealed subclasses that may be either instantiated or subclassed.
* <ul>
* <li>If a mutable target is not required, an {@code invokedynamic} instruction
* may be permanently bound by means of a {@linkplain ConstantCallSite constant call site}.
@@ -85,7 +85,7 @@ private static CallSite bootstrapDynamic(MethodHandles.Lookup caller, String nam
* @since 1.7
*/
public
-abstract class CallSite {
+abstract sealed class CallSite permits ConstantCallSite, MutableCallSite, VolatileCallSite {
// The actual payload of this call site.
// Can be modified using {@link MethodHandleNatives#setCallSiteTargetNormal} or {@link MethodHandleNatives#setCallSiteTargetVolatile}.
diff --git a/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java b/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java
index e2e3f478a3c..833cd5b117a 100644
--- a/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java
+++ b/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java
@@ -35,7 +35,7 @@ import jdk.internal.vm.annotation.Stable;
* @author John Rose, JSR 292 EG
* @since 1.7
*/
-public class ConstantCallSite extends CallSite {
+public non-sealed class ConstantCallSite extends CallSite {
private static final Unsafe UNSAFE = Unsafe.getUnsafe();
@Stable // should NOT be constant folded during instance initialization (isFrozen == false)
diff --git a/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java b/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java
index c16483d02ae..c100657df6b 100644
--- a/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java
+++ b/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java
@@ -83,7 +83,7 @@ assertEquals("Wilma, dear?", (String) worker2.invokeExact());
* @author John Rose, JSR 292 EG
* @since 1.7
*/
-public class MutableCallSite extends CallSite {
+public non-sealed class MutableCallSite extends CallSite {
/**
* Creates a blank call site object with the given method type.
* The initial target is set to a method handle of the given type
diff --git a/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java b/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java
index 742fa23737d..ea068ff07e6 100644
--- a/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java
+++ b/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java
@@ -42,7 +42,7 @@ package java.lang.invoke;
* @author John Rose, JSR 292 EG
* @since 1.7
*/
-public class VolatileCallSite extends CallSite {
+public non-sealed class VolatileCallSite extends CallSite {
/**
* Creates a call site with a volatile binding to its target.
* The initial target is set to a method handle
```