8315938: Deprecate for removal Unsafe methods that have standard APIs for many releases

Reviewed-by: mchung, psandoz, iris
This commit is contained in:
Alan Bateman 2023-09-12 07:19:05 +00:00
parent fda142ff6c
commit d08258f735

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -1089,7 +1089,10 @@ public final class Unsafe {
* so when calling from native code. * so when calling from native code.
* *
* @param thread the thread to unpark. * @param thread the thread to unpark.
*
* @deprecated Use {@link java.util.concurrent.locks.LockSupport#unpark(Thread)} instead.
*/ */
@Deprecated(since="22", forRemoval=true)
@ForceInline @ForceInline
public void unpark(Object thread) { public void unpark(Object thread) {
theInternalUnsafe.unpark(thread); theInternalUnsafe.unpark(thread);
@ -1105,7 +1108,11 @@ public final class Unsafe {
* "reason"). Note: This operation is in the Unsafe class only * "reason"). Note: This operation is in the Unsafe class only
* because {@code unpark} is, so it would be strange to place it * because {@code unpark} is, so it would be strange to place it
* elsewhere. * elsewhere.
*
* @deprecated Use {@link java.util.concurrent.locks.LockSupport#parkNanos(long)} or
* {@link java.util.concurrent.locks.LockSupport#parkUntil(long)} instead.
*/ */
@Deprecated(since="22", forRemoval=true)
@ForceInline @ForceInline
public void park(boolean isAbsolute, long time) { public void park(boolean isAbsolute, long time) {
theInternalUnsafe.park(isAbsolute, time); theInternalUnsafe.park(isAbsolute, time);
@ -1125,7 +1132,11 @@ public final class Unsafe {
* *
* @return the number of samples actually retrieved; or -1 * @return the number of samples actually retrieved; or -1
* if the load average is unobtainable. * if the load average is unobtainable.
*
* @deprecated Use {@link java.lang.management.OperatingSystemMXBean#getSystemLoadAverage()}
* instead.
*/ */
@Deprecated(since="22", forRemoval=true)
@ForceInline @ForceInline
public int getLoadAverage(double[] loadavg, int nelems) { public int getLoadAverage(double[] loadavg, int nelems) {
return theInternalUnsafe.getLoadAverage(loadavg, nelems); return theInternalUnsafe.getLoadAverage(loadavg, nelems);
@ -1214,7 +1225,6 @@ public final class Unsafe {
return theInternalUnsafe.getAndSetReference(o, offset, newValue); return theInternalUnsafe.getAndSetReference(o, offset, newValue);
} }
/** /**
* Ensures that loads before the fence will not be reordered with loads and * Ensures that loads before the fence will not be reordered with loads and
* stores after the fence; a "LoadLoad plus LoadStore barrier". * stores after the fence; a "LoadLoad plus LoadStore barrier".
@ -1225,8 +1235,11 @@ public final class Unsafe {
* A pure LoadLoad fence is not provided, since the addition of LoadStore * A pure LoadLoad fence is not provided, since the addition of LoadStore
* is almost always desired, and most current hardware instructions that * is almost always desired, and most current hardware instructions that
* provide a LoadLoad barrier also provide a LoadStore barrier for free. * provide a LoadLoad barrier also provide a LoadStore barrier for free.
*
* @deprecated Use {@link java.lang.invoke.VarHandle#acquireFence()} instead.
* @since 1.8 * @since 1.8
*/ */
@Deprecated(since="22", forRemoval=true)
@ForceInline @ForceInline
public void loadFence() { public void loadFence() {
theInternalUnsafe.loadFence(); theInternalUnsafe.loadFence();
@ -1242,8 +1255,11 @@ public final class Unsafe {
* A pure StoreStore fence is not provided, since the addition of LoadStore * A pure StoreStore fence is not provided, since the addition of LoadStore
* is almost always desired, and most current hardware instructions that * is almost always desired, and most current hardware instructions that
* provide a StoreStore barrier also provide a LoadStore barrier for free. * provide a StoreStore barrier also provide a LoadStore barrier for free.
*
* @deprecated Use {@link java.lang.invoke.VarHandle#releaseFence()} instead.
* @since 1.8 * @since 1.8
*/ */
@Deprecated(since="22", forRemoval=true)
@ForceInline @ForceInline
public void storeFence() { public void storeFence() {
theInternalUnsafe.storeFence(); theInternalUnsafe.storeFence();
@ -1256,8 +1272,11 @@ public final class Unsafe {
* barrier. * barrier.
* *
* Corresponds to C11 atomic_thread_fence(memory_order_seq_cst). * Corresponds to C11 atomic_thread_fence(memory_order_seq_cst).
*
* @deprecated Use {@link java.lang.invoke.VarHandle#fullFence()} instead.
* @since 1.8 * @since 1.8
*/ */
@Deprecated(since="22", forRemoval=true)
@ForceInline @ForceInline
public void fullFence() { public void fullFence() {
theInternalUnsafe.fullFence(); theInternalUnsafe.fullFence();