-
CSR
-
Resolution: Approved
-
P4
-
None
-
source
-
minimal
-
Since MethodHandle was already not user-subclassable, now it is not user subclassable in a second way.
-
Java API
-
SE
Summary
Update MethodHandle
to be a sealed class.
Problem
The MethodHandle
class is not intended to have user-defined subclasses and sealing is an explicit way to indicate this.
Solution
Update the class to be declared 'sealed`. Other needed changes are implementation-only and not part of the user-visible API change listed in this CSR.
Specification
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java
@@ -440,7 +440,9 @@ mh.invokeExact(System.out, "Hello, world.");
* @author John Rose, JSR 292 EG
* @since 1.7
*/
-public abstract class MethodHandle implements Constable {
+public abstract sealed class MethodHandle implements Constable
+ permits NativeMethodHandle, DirectMethodHandle,
+ DelegatingMethodHandle, BoundMethodHandle {
/**
* Internal marker interface which distinguishes (to the Java compiler)
- csr of
-
JDK-8283416 Update java.lang.invoke.MethodHandle to use sealed classes
-
- Resolved
-