Skip to content

Commit

Permalink
8315938: Deprecate for removal Unsafe methods that have standard APIs…
Browse files Browse the repository at this point in the history
… for many releases

Reviewed-by: mchung, psandoz, iris
  • Loading branch information
Alan Bateman committed Sep 12, 2023
1 parent fda142f commit d08258f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1089,7 +1089,10 @@ public void putOrderedLong(Object o, long offset, long x) {
* so when calling from native code.
*
* @param thread the thread to unpark.
*
* @deprecated Use {@link java.util.concurrent.locks.LockSupport#unpark(Thread)} instead.
*/
@Deprecated(since="22", forRemoval=true)
@ForceInline
public void unpark(Object thread) {
theInternalUnsafe.unpark(thread);
Expand All @@ -1105,7 +1108,11 @@ public void unpark(Object thread) {
* "reason"). Note: This operation is in the Unsafe class only
* because {@code unpark} is, so it would be strange to place it
* 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
public void park(boolean isAbsolute, long time) {
theInternalUnsafe.park(isAbsolute, time);
Expand All @@ -1125,7 +1132,11 @@ public void park(boolean isAbsolute, long time) {
*
* @return the number of samples actually retrieved; or -1
* if the load average is unobtainable.
*
* @deprecated Use {@link java.lang.management.OperatingSystemMXBean#getSystemLoadAverage()}
* instead.
*/
@Deprecated(since="22", forRemoval=true)
@ForceInline
public int getLoadAverage(double[] loadavg, int nelems) {
return theInternalUnsafe.getLoadAverage(loadavg, nelems);
Expand Down Expand Up @@ -1214,7 +1225,6 @@ public final Object getAndSetObject(Object o, long offset, Object newValue) {
return theInternalUnsafe.getAndSetReference(o, offset, newValue);
}


/**
* Ensures that loads before the fence will not be reordered with loads and
* stores after the fence; a "LoadLoad plus LoadStore barrier".
Expand All @@ -1225,8 +1235,11 @@ public final Object getAndSetObject(Object o, long offset, Object newValue) {
* A pure LoadLoad fence is not provided, since the addition of LoadStore
* is almost always desired, and most current hardware instructions that
* provide a LoadLoad barrier also provide a LoadStore barrier for free.
*
* @deprecated Use {@link java.lang.invoke.VarHandle#acquireFence()} instead.
* @since 1.8
*/
@Deprecated(since="22", forRemoval=true)
@ForceInline
public void loadFence() {
theInternalUnsafe.loadFence();
Expand All @@ -1242,8 +1255,11 @@ public void loadFence() {
* A pure StoreStore fence is not provided, since the addition of LoadStore
* is almost always desired, and most current hardware instructions that
* provide a StoreStore barrier also provide a LoadStore barrier for free.
*
* @deprecated Use {@link java.lang.invoke.VarHandle#releaseFence()} instead.
* @since 1.8
*/
@Deprecated(since="22", forRemoval=true)
@ForceInline
public void storeFence() {
theInternalUnsafe.storeFence();
Expand All @@ -1256,8 +1272,11 @@ public void storeFence() {
* barrier.
*
* Corresponds to C11 atomic_thread_fence(memory_order_seq_cst).
*
* @deprecated Use {@link java.lang.invoke.VarHandle#fullFence()} instead.
* @since 1.8
*/
@Deprecated(since="22", forRemoval=true)
@ForceInline
public void fullFence() {
theInternalUnsafe.fullFence();
Expand Down

1 comment on commit d08258f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.