8283237: CallSite should be a sealed class

Reviewed-by: jkuhn, mchung
This commit is contained in:
liach 2022-03-23 16:43:06 +00:00 committed by Mandy Chung
parent a77160065b
commit 3e73a0b726
4 changed files with 10 additions and 10 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -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}.

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -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)

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -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

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -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