--- old/src/java.base/share/classes/module-info.java 2018-11-02 08:21:39.000000000 -0700
+++ new/src/java.base/share/classes/module-info.java 2018-11-02 08:21:38.000000000 -0700
@@ -189,7 +189,6 @@
jdk.net,
jdk.scripting.nashorn,
jdk.scripting.nashorn.shell,
- jdk.unsupported,
jdk.internal.vm.ci;
exports jdk.internal.module to
java.instrument,
@@ -202,8 +201,7 @@
jdk.management.agent,
jdk.internal.jvmstat;
exports jdk.internal.ref to
- java.desktop,
- jdk.unsupported;
+ java.desktop;
exports jdk.internal.reflect to
java.logging,
java.sql,
@@ -211,6 +209,8 @@
jdk.dynalink,
jdk.scripting.nashorn,
jdk.unsupported;
+ exports jdk.internal.unsupported to
+ jdk.unsupported;
exports jdk.internal.vm to
jdk.internal.jvmstat,
jdk.management.agent;
@@ -244,12 +244,9 @@
java.management,
jdk.crypto.cryptoki,
jdk.net,
- jdk.sctp,
- jdk.unsupported;
+ jdk.sctp;
exports sun.nio.cs to
jdk.charsets;
- exports sun.nio.fs to
- jdk.unsupported;
exports sun.reflect.annotation to
jdk.compiler;
exports sun.reflect.generics.reflectiveObjects to
--- old/src/jdk.unsupported/share/classes/com/sun/nio/file/ExtendedCopyOption.java 2018-11-02 08:21:41.000000000 -0700
+++ new/src/jdk.unsupported/share/classes/com/sun/nio/file/ExtendedCopyOption.java 2018-11-02 08:21:40.000000000 -0700
@@ -26,7 +26,7 @@
package com.sun.nio.file;
import java.nio.file.CopyOption;
-import sun.nio.fs.ExtendedOptions;
+import jdk.internal.unsupported.FileSystemOption;
/**
* Defines extended copy options supported on some platforms
@@ -40,9 +40,9 @@
* The copy may be interrupted by the {@link Thread#interrupt interrupt}
* method.
*/
- INTERRUPTIBLE(ExtendedOptions.INTERRUPTIBLE);
+ INTERRUPTIBLE(FileSystemOption.INTERRUPTIBLE);
- ExtendedCopyOption(ExtendedOptions.InternalOption option) {
+ ExtendedCopyOption(FileSystemOption option) {
option.register(this);
}
}
--- old/src/jdk.unsupported/share/classes/com/sun/nio/file/ExtendedOpenOption.java 2018-11-02 08:21:42.000000000 -0700
+++ new/src/jdk.unsupported/share/classes/com/sun/nio/file/ExtendedOpenOption.java 2018-11-02 08:21:41.000000000 -0700
@@ -26,7 +26,7 @@
package com.sun.nio.file;
import java.nio.file.OpenOption;
-import sun.nio.fs.ExtendedOptions;
+import jdk.internal.unsupported.FileSystemOption;
/**
* Defines extended open options supported on some platforms
@@ -39,15 +39,15 @@
/**
* Prevent operations on the file that request read access.
*/
- NOSHARE_READ(ExtendedOptions.NOSHARE_READ),
+ NOSHARE_READ(FileSystemOption.NOSHARE_READ),
/**
* Prevent operations on the file that request write access.
*/
- NOSHARE_WRITE(ExtendedOptions.NOSHARE_WRITE),
+ NOSHARE_WRITE(FileSystemOption.NOSHARE_WRITE),
/**
* Prevent operations on the file that request delete access.
*/
- NOSHARE_DELETE(ExtendedOptions.NOSHARE_DELETE),
+ NOSHARE_DELETE(FileSystemOption.NOSHARE_DELETE),
/**
* Requires that direct I/O be used for read or write access.
@@ -69,9 +69,9 @@
*
* @since 10
*/
- DIRECT(ExtendedOptions.DIRECT);
+ DIRECT(FileSystemOption.DIRECT);
- ExtendedOpenOption(ExtendedOptions.InternalOption option) {
+ ExtendedOpenOption(FileSystemOption option) {
option.register(this);
}
}
--- old/src/jdk.unsupported/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java 2018-11-02 08:21:43.000000000 -0700
+++ new/src/jdk.unsupported/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java 2018-11-02 08:21:43.000000000 -0700
@@ -26,7 +26,7 @@
package com.sun.nio.file;
import java.nio.file.WatchEvent.Modifier;
-import sun.nio.fs.ExtendedOptions;
+import jdk.internal.unsupported.FileSystemOption;
/**
* Defines extended watch event modifiers supported on some platforms
@@ -40,9 +40,9 @@
/**
* Register a file tree instead of a single directory.
*/
- FILE_TREE(ExtendedOptions.FILE_TREE);
+ FILE_TREE(FileSystemOption.FILE_TREE);
- ExtendedWatchEventModifier(ExtendedOptions.InternalOption option) {
+ ExtendedWatchEventModifier(FileSystemOption option) {
option.register(this);
}
}
--- old/src/jdk.unsupported/share/classes/com/sun/nio/file/SensitivityWatchEventModifier.java 2018-11-02 08:21:44.000000000 -0700
+++ new/src/jdk.unsupported/share/classes/com/sun/nio/file/SensitivityWatchEventModifier.java 2018-11-02 08:21:44.000000000 -0700
@@ -26,7 +26,7 @@
package com.sun.nio.file;
import java.nio.file.WatchEvent.Modifier;
-import sun.nio.fs.ExtendedOptions;
+import jdk.internal.unsupported.FileSystemOption;
/**
* Defines the sensitivity levels when registering objects with a
@@ -39,15 +39,15 @@
/**
* High sensitivity.
*/
- HIGH(ExtendedOptions.SENSITIVITY_HIGH, 2),
+ HIGH(FileSystemOption.SENSITIVITY_HIGH, 2),
/**
* Medium sensitivity.
*/
- MEDIUM(ExtendedOptions.SENSITIVITY_MEDIUM, 10),
+ MEDIUM(FileSystemOption.SENSITIVITY_MEDIUM, 10),
/**
* Low sensitivity.
*/
- LOW(ExtendedOptions.SENSITIVITY_LOW, 30);
+ LOW(FileSystemOption.SENSITIVITY_LOW, 30);
/**
* Returns the sensitivity in seconds.
@@ -57,7 +57,7 @@
}
private final int sensitivity;
- private SensitivityWatchEventModifier(ExtendedOptions.InternalOption option,
+ private SensitivityWatchEventModifier(FileSystemOption option,
int sensitivity) {
this.sensitivity = sensitivity;
option.register(this, sensitivity);
--- old/src/jdk.unsupported/share/classes/sun/misc/Signal.java 2018-11-02 08:21:46.000000000 -0700
+++ new/src/jdk.unsupported/share/classes/sun/misc/Signal.java 2018-11-02 08:21:45.000000000 -0700
@@ -25,7 +25,7 @@
package sun.misc;
-import java.util.Objects;
+import jdk.internal.unsupported.SignalDelegate;
/**
* This class provides ANSI/ISO C signal support. A Java program can register
@@ -74,8 +74,7 @@
*/
public final class Signal {
- // Delegate to jdk.internal.misc.Signal.
- private final jdk.internal.misc.Signal iSignal;
+ private final SignalDelegate iSignal;
/* Returns the signal number */
public int getNumber() {
@@ -136,7 +135,7 @@
* @see sun.misc.Signal#getName()
*/
public Signal(String name) {
- iSignal = new jdk.internal.misc.Signal(name);
+ iSignal = new SignalDelegate(name);
}
/**
@@ -154,8 +153,8 @@
public static synchronized SignalHandler handle(Signal sig,
SignalHandler handler)
throws IllegalArgumentException {
- jdk.internal.misc.Signal.Handler oldHandler = jdk.internal.misc.Signal.handle(sig.iSignal,
- InternalMiscHandler.of(sig, handler));
+ SignalDelegate.Handler oldHandler = SignalDelegate.handle(sig.iSignal,
+ SignalDelegateHandler.of(sig, handler));
return SunMiscHandler.of(sig.iSignal, oldHandler);
}
@@ -166,59 +165,59 @@
* @see sun.misc.Signal#handle(Signal sig, SignalHandler handler)
*/
public static void raise(Signal sig) throws IllegalArgumentException {
- jdk.internal.misc.Signal.raise(sig.iSignal);
+ SignalDelegate.raise(sig.iSignal);
}
/*
- * Wrapper class to proxy a SignalHandler to a jdk.internal.misc.Signal.Handler.
+ * Wrapper class to proxy a SignalHandler to a jdk.internal.unsupported.SunMiscSignal.Handler.
*/
- static final class InternalMiscHandler implements jdk.internal.misc.Signal.Handler {
+ static final class SignalDelegateHandler implements SignalDelegate.Handler {
private final SignalHandler handler;
private final Signal signal;
- static jdk.internal.misc.Signal.Handler of(Signal signal, SignalHandler handler) {
+ static SignalDelegate.Handler of(Signal signal, SignalHandler handler) {
if (handler == SignalHandler.SIG_DFL) {
- return jdk.internal.misc.Signal.Handler.SIG_DFL;
+ return SignalDelegate.Handler.SIG_DFL;
} else if (handler == SignalHandler.SIG_IGN) {
- return jdk.internal.misc.Signal.Handler.SIG_IGN;
+ return SignalDelegate.Handler.SIG_IGN;
} else if (handler instanceof SunMiscHandler) {
return ((SunMiscHandler)handler).iHandler;
} else {
- return new InternalMiscHandler(signal, handler);
+ return new SignalDelegateHandler(signal, handler);
}
}
- private InternalMiscHandler(Signal signal, SignalHandler handler) {
+ private SignalDelegateHandler(Signal signal, SignalHandler handler) {
this.handler = handler;
this.signal = signal;
}
@Override
- public void handle(jdk.internal.misc.Signal ignore) {
+ public void handle(SignalDelegate ignore) {
handler.handle(signal);
}
}
/*
- * Wrapper class to proxy a jdk.internal.misc.Signal.Handler to a SignalHandler.
+ * Wrapper class to proxy a jdk.internal.unsupported.SunMiscSignal.Handler to a SignalHandler.
*/
static final class SunMiscHandler implements SignalHandler {
- private final jdk.internal.misc.Signal iSignal;
- private final jdk.internal.misc.Signal.Handler iHandler;
+ private final SignalDelegate iSignal;
+ private final SignalDelegate.Handler iHandler;
- static SignalHandler of(jdk.internal.misc.Signal signal, jdk.internal.misc.Signal.Handler handler) {
- if (handler == jdk.internal.misc.Signal.Handler.SIG_DFL) {
+ static SignalHandler of(SignalDelegate signal, SignalDelegate.Handler handler) {
+ if (handler == SignalDelegate.Handler.SIG_DFL) {
return SignalHandler.SIG_DFL;
- } else if (handler == jdk.internal.misc.Signal.Handler.SIG_IGN) {
+ } else if (handler == SignalDelegate.Handler.SIG_IGN) {
return SignalHandler.SIG_IGN;
- } else if (handler instanceof InternalMiscHandler) {
- return ((InternalMiscHandler) handler).handler;
+ } else if (handler instanceof SignalDelegateHandler) {
+ return ((SignalDelegateHandler) handler).handler;
} else {
return new SunMiscHandler(signal, handler);
}
}
- SunMiscHandler(jdk.internal.misc.Signal iSignal, jdk.internal.misc.Signal.Handler iHandler) {
+ SunMiscHandler(SignalDelegate iSignal, SignalDelegate.Handler iHandler) {
this.iSignal = iSignal;
this.iHandler = iHandler;
}
--- old/src/jdk.unsupported/share/classes/sun/misc/SignalHandler.java 2018-11-02 08:21:47.000000000 -0700
+++ new/src/jdk.unsupported/share/classes/sun/misc/SignalHandler.java 2018-11-02 08:21:47.000000000 -0700
@@ -25,6 +25,8 @@
package sun.misc;
+import jdk.internal.unsupported.SignalDelegate;
+
/**
* This is the signal handler interface expected in Signal.handle
.
*
@@ -40,12 +42,12 @@
* The default signal handler
*/
public static final SignalHandler SIG_DFL =
- new Signal.SunMiscHandler(null, jdk.internal.misc.Signal.Handler.SIG_DFL);
+ new Signal.SunMiscHandler(null, SignalDelegate.Handler.SIG_DFL);
/**
* Ignore the signal
*/
public static final SignalHandler SIG_IGN =
- new Signal.SunMiscHandler(null, jdk.internal.misc.Signal.Handler.SIG_IGN);
+ new Signal.SunMiscHandler(null, SignalDelegate.Handler.SIG_IGN);
/**
* Handle the given signal
--- old/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java 2018-11-02 08:21:49.000000000 -0700
+++ new/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java 2018-11-02 08:21:48.000000000 -0700
@@ -25,12 +25,10 @@
package sun.misc;
+import jdk.internal.unsupported.UnsafeForwarder;
import jdk.internal.vm.annotation.ForceInline;
-import jdk.internal.misc.VM;
-import jdk.internal.ref.Cleaner;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
-import sun.nio.ch.DirectBuffer;
import java.lang.reflect.Field;
import java.util.Set;
@@ -63,7 +61,7 @@
private Unsafe() {}
private static final Unsafe theUnsafe = new Unsafe();
- private static final jdk.internal.misc.Unsafe theInternalUnsafe = jdk.internal.misc.Unsafe.getUnsafe();
+ private static final UnsafeForwarder theInternalUnsafe = UnsafeForwarder.getUnsafeHelper();
/**
* Provides the caller with the capability of performing unsafe
@@ -96,8 +94,9 @@
@CallerSensitive
public static Unsafe getUnsafe() {
Class> caller = Reflection.getCallerClass();
- if (!VM.isSystemDomainLoader(caller.getClassLoader()))
- throw new SecurityException("Unsafe");
+ ClassLoader loader = caller.getClassLoader();
+ if (loader != null && loader != ClassLoader.getPlatformClassLoader())
+ throw new SecurityException("Unsafe");
return theUnsafe;
}
@@ -616,7 +615,7 @@
* {@link #staticFieldOffset}, {@link #objectFieldOffset},
* or {@link #arrayBaseOffset}.
*/
- public static final int INVALID_FIELD_OFFSET = jdk.internal.misc.Unsafe.INVALID_FIELD_OFFSET;
+ public static final int INVALID_FIELD_OFFSET = jdk.internal.unsupported.UnsafeForwarder.INVALID_FIELD_OFFSET;
/**
* Reports the location of a given field in the storage allocation of its
@@ -715,31 +714,31 @@
}
/** The value of {@code arrayBaseOffset(boolean[].class)} */
- public static final int ARRAY_BOOLEAN_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
+ public static final int ARRAY_BOOLEAN_BASE_OFFSET = jdk.internal.unsupported.UnsafeForwarder.ARRAY_BOOLEAN_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(byte[].class)} */
- public static final int ARRAY_BYTE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET;
+ public static final int ARRAY_BYTE_BASE_OFFSET = jdk.internal.unsupported.UnsafeForwarder.ARRAY_BYTE_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(short[].class)} */
- public static final int ARRAY_SHORT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_SHORT_BASE_OFFSET;
+ public static final int ARRAY_SHORT_BASE_OFFSET = jdk.internal.unsupported.UnsafeForwarder.ARRAY_SHORT_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(char[].class)} */
- public static final int ARRAY_CHAR_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_CHAR_BASE_OFFSET;
+ public static final int ARRAY_CHAR_BASE_OFFSET = jdk.internal.unsupported.UnsafeForwarder.ARRAY_CHAR_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(int[].class)} */
- public static final int ARRAY_INT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_INT_BASE_OFFSET;
+ public static final int ARRAY_INT_BASE_OFFSET = jdk.internal.unsupported.UnsafeForwarder.ARRAY_INT_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(long[].class)} */
- public static final int ARRAY_LONG_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_LONG_BASE_OFFSET;
+ public static final int ARRAY_LONG_BASE_OFFSET = jdk.internal.unsupported.UnsafeForwarder.ARRAY_LONG_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(float[].class)} */
- public static final int ARRAY_FLOAT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_FLOAT_BASE_OFFSET;
+ public static final int ARRAY_FLOAT_BASE_OFFSET = jdk.internal.unsupported.UnsafeForwarder.ARRAY_FLOAT_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(double[].class)} */
- public static final int ARRAY_DOUBLE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_DOUBLE_BASE_OFFSET;
+ public static final int ARRAY_DOUBLE_BASE_OFFSET = jdk.internal.unsupported.UnsafeForwarder.ARRAY_DOUBLE_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(Object[].class)} */
- public static final int ARRAY_OBJECT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_OBJECT_BASE_OFFSET;
+ public static final int ARRAY_OBJECT_BASE_OFFSET = jdk.internal.unsupported.UnsafeForwarder.ARRAY_OBJECT_BASE_OFFSET;
/**
* Reports the scale factor for addressing elements in the storage
@@ -758,31 +757,31 @@
}
/** The value of {@code arrayIndexScale(boolean[].class)} */
- public static final int ARRAY_BOOLEAN_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_INDEX_SCALE;
+ public static final int ARRAY_BOOLEAN_INDEX_SCALE = jdk.internal.unsupported.UnsafeForwarder.ARRAY_BOOLEAN_INDEX_SCALE;
/** The value of {@code arrayIndexScale(byte[].class)} */
- public static final int ARRAY_BYTE_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_BYTE_INDEX_SCALE;
+ public static final int ARRAY_BYTE_INDEX_SCALE = jdk.internal.unsupported.UnsafeForwarder.ARRAY_BYTE_INDEX_SCALE;
/** The value of {@code arrayIndexScale(short[].class)} */
- public static final int ARRAY_SHORT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_SHORT_INDEX_SCALE;
+ public static final int ARRAY_SHORT_INDEX_SCALE = jdk.internal.unsupported.UnsafeForwarder.ARRAY_SHORT_INDEX_SCALE;
/** The value of {@code arrayIndexScale(char[].class)} */
- public static final int ARRAY_CHAR_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_CHAR_INDEX_SCALE;
+ public static final int ARRAY_CHAR_INDEX_SCALE = jdk.internal.unsupported.UnsafeForwarder.ARRAY_CHAR_INDEX_SCALE;
/** The value of {@code arrayIndexScale(int[].class)} */
- public static final int ARRAY_INT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_INT_INDEX_SCALE;
+ public static final int ARRAY_INT_INDEX_SCALE = jdk.internal.unsupported.UnsafeForwarder.ARRAY_INT_INDEX_SCALE;
/** The value of {@code arrayIndexScale(long[].class)} */
- public static final int ARRAY_LONG_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_LONG_INDEX_SCALE;
+ public static final int ARRAY_LONG_INDEX_SCALE = jdk.internal.unsupported.UnsafeForwarder.ARRAY_LONG_INDEX_SCALE;
/** The value of {@code arrayIndexScale(float[].class)} */
- public static final int ARRAY_FLOAT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_FLOAT_INDEX_SCALE;
+ public static final int ARRAY_FLOAT_INDEX_SCALE = jdk.internal.unsupported.UnsafeForwarder.ARRAY_FLOAT_INDEX_SCALE;
/** The value of {@code arrayIndexScale(double[].class)} */
- public static final int ARRAY_DOUBLE_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_DOUBLE_INDEX_SCALE;
+ public static final int ARRAY_DOUBLE_INDEX_SCALE = jdk.internal.unsupported.UnsafeForwarder.ARRAY_DOUBLE_INDEX_SCALE;
/** The value of {@code arrayIndexScale(Object[].class)} */
- public static final int ARRAY_OBJECT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_OBJECT_INDEX_SCALE;
+ public static final int ARRAY_OBJECT_INDEX_SCALE = jdk.internal.unsupported.UnsafeForwarder.ARRAY_OBJECT_INDEX_SCALE;
/**
* Reports the size in bytes of a native pointer, as stored via {@link
@@ -1076,16 +1075,23 @@
* The system imposes a maximum of 3 samples, representing
* averages over the last 1, 5, and 15 minutes, respectively.
*
+ * @implNote This method returns -1.
+ *
* @param loadavg an array of double of size nelems
* @param nelems the number of samples to be retrieved and
* must be 1 to 3.
*
* @return the number of samples actually retrieved; or -1
* if the load average is unobtainable.
+ *
+ * @deprecated This method is planned to be removed in a future release.
+ * To get system load average, use
+ * {@link java.lang.management.OperatingSystemMXBean#getSystemLoadAverage()}
+ * instead.
*/
- @ForceInline
+ @Deprecated(since="12", forRemoval=true)
public int getLoadAverage(double[] loadavg, int nelems) {
- return theInternalUnsafe.getLoadAverage(loadavg, nelems);
+ return -1;
}
// The following contain CAS-based Java implementations used on
@@ -1234,13 +1240,6 @@
if (!directBuffer.isDirect())
throw new IllegalArgumentException("buffer is non-direct");
- DirectBuffer db = (DirectBuffer)directBuffer;
- if (db.attachment() != null)
- throw new IllegalArgumentException("duplicate or slice");
-
- Cleaner cleaner = db.cleaner();
- if (cleaner != null) {
- cleaner.clean();
- }
+ theInternalUnsafe.invokeCleaner(directBuffer);
}
}
--- /dev/null 2018-11-02 08:21:51.000000000 -0700
+++ new/src/java.base/share/classes/jdk/internal/unsupported/FileSystemOption.java 2018-11-02 08:21:50.000000000 -0700
@@ -0,0 +1,65 @@
+package jdk.internal.unsupported;
+
+import sun.nio.fs.ExtendedOptions;
+
+import java.nio.file.CopyOption;
+import java.nio.file.OpenOption;
+import java.nio.file.WatchEvent;
+
+/**
+ * Internal file system options for com.sun.nio.file package.
+ */
+public final class FileSystemOption {
+ public static final FileSystemOption INTERRUPTIBLE =
+ new FileSystemOption<>(ExtendedOptions.INTERRUPTIBLE);
+ public static final FileSystemOption NOSHARE_READ =
+ new FileSystemOption<>(ExtendedOptions.NOSHARE_READ);
+ public static final FileSystemOption NOSHARE_WRITE =
+ new FileSystemOption<>(ExtendedOptions.NOSHARE_WRITE);
+ public static final FileSystemOption NOSHARE_DELETE =
+ new FileSystemOption<>(ExtendedOptions.NOSHARE_DELETE);
+ public static final FileSystemOption FILE_TREE =
+ new FileSystemOption<>(ExtendedOptions.FILE_TREE);
+ public static final FileSystemOption DIRECT =
+ new FileSystemOption<>(ExtendedOptions.DIRECT);
+ public static final FileSystemOption SENSITIVITY_HIGH =
+ new FileSystemOption<>(ExtendedOptions.SENSITIVITY_HIGH);
+ public static final FileSystemOption SENSITIVITY_MEDIUM =
+ new FileSystemOption<>(ExtendedOptions.SENSITIVITY_MEDIUM);
+ public static final FileSystemOption SENSITIVITY_LOW =
+ new FileSystemOption<>(ExtendedOptions.SENSITIVITY_LOW);
+
+ private final ExtendedOptions.InternalOption internalOption;
+ private FileSystemOption(ExtendedOptions.InternalOption option) {
+ this.internalOption = option;
+ }
+
+ /**
+ * Register this internal option as a OpenOption.
+ */
+ public void register(OpenOption option) {
+ internalOption.register(option);
+ }
+
+ /**
+ * Register this internal option as a CopyOption.
+ */
+ public void register(CopyOption option) {
+ internalOption.register(option);
+ }
+
+ /**
+ * Register this internal option as a WatchEvent.Modifier.
+ */
+ public void register(WatchEvent.Modifier option) {
+ internalOption.register(option);
+ }
+
+ /**
+ * Register this internal option as a WatchEvent.Modifier with the
+ * given parameter.
+ */
+ public void register(WatchEvent.Modifier option, T param) {
+ internalOption.register(option, param);
+ }
+}
--- /dev/null 2018-11-02 08:21:52.000000000 -0700
+++ new/src/java.base/share/classes/jdk/internal/unsupported/SignalDelegate.java 2018-11-02 08:21:52.000000000 -0700
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.unsupported;
+
+public final class SignalDelegate {
+ // Delegate to jdk.internal.misc.Signal.
+ private final jdk.internal.misc.Signal iSignal;
+
+ /**
+ * Constructs a signal from its name.
+ *
+ * @param name the name of the signal.
+ * @exception IllegalArgumentException unknown signal
+ */
+ public SignalDelegate(String name) {
+ iSignal = new jdk.internal.misc.Signal(name);
+ }
+
+ /* Returns the signal number */
+ public int getNumber() {
+ return iSignal.getNumber();
+ }
+
+ /**
+ * Returns the signal name.
+ *
+ * @return the name of the signal.
+ */
+ public String getName() {
+ return iSignal.getName();
+ }
+
+ /**
+ * Compares the equality of two Signal
objects.
+ *
+ * @param other the object to compare with.
+ * @return whether two Signal
objects are equal.
+ */
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (other == null || !(other instanceof SignalDelegate)) {
+ return false;
+ }
+ SignalDelegate other1 = (SignalDelegate)other;
+ return iSignal.equals(other1.iSignal);
+ }
+
+ /**
+ * Returns a hashcode for this Signal.
+ *
+ * @return a hash code value for this object.
+ */
+ public int hashCode() {
+ return getNumber();
+ }
+
+ /**
+ * Returns a string representation of this signal. For example, "SIGINT"
+ * for an object constructed using new Signal ("INT")
.
+ *
+ * @return a string representation of the signal
+ */
+ public String toString() {
+ return iSignal.toString();
+ }
+
+
+ /**
+ * Registers a signal handler.
+ *
+ * @param sig a signal
+ * @param handler the handler to be registered with the given signal.
+ * @return the old handler
+ * @exception IllegalArgumentException the signal is in use by the VM
+ */
+ public static synchronized Handler handle(SignalDelegate sig, Handler handler) {
+ jdk.internal.misc.Signal.Handler oldHandler = jdk.internal.misc.Signal.handle(sig.iSignal,
+ InternalMiscHandler.of(sig, handler));
+ return new HandlerProxy(sig.iSignal, oldHandler);
+ }
+
+ /**
+ * Raises a signal in the current process.
+ *
+ * @param sig a signal
+ */
+ public static void raise(SignalDelegate sig) throws IllegalArgumentException {
+ jdk.internal.misc.Signal.raise(sig.iSignal);
+ }
+
+ public interface Handler {
+ /**
+ * The default signal handler
+ */
+ public static final Handler SIG_DFL =
+ new HandlerProxy(null, jdk.internal.misc.Signal.Handler.SIG_DFL);
+
+ /**
+ * Ignore the signal
+ */
+ public static final Handler SIG_IGN =
+ new HandlerProxy(null, jdk.internal.misc.Signal.Handler.SIG_IGN);
+
+
+ public void handle(SignalDelegate ignore);
+ }
+
+ static class HandlerProxy implements Handler {
+ private final jdk.internal.misc.Signal iSignal;
+ private final jdk.internal.misc.Signal.Handler iHandler;
+
+ static Handler of(jdk.internal.misc.Signal signal, jdk.internal.misc.Signal.Handler handler) {
+ if (handler == SignalDelegate.Handler.SIG_DFL) {
+ return Handler.SIG_DFL;
+ } else if (handler == SignalDelegate.Handler.SIG_IGN) {
+ return Handler.SIG_IGN;
+ } else if (handler instanceof InternalMiscHandler) {
+ return ((InternalMiscHandler) handler).handler;
+ } else {
+ return new HandlerProxy(signal, handler);
+ }
+ }
+
+ HandlerProxy(jdk.internal.misc.Signal iSignal, jdk.internal.misc.Signal.Handler iHandler) {
+ this.iSignal = iSignal;
+ this.iHandler = iHandler;
+ }
+
+ @Override
+ public void handle(SignalDelegate ignore) {
+ iHandler.handle(iSignal);
+ }
+ }
+
+ static final class InternalMiscHandler implements jdk.internal.misc.Signal.Handler {
+ private final Handler handler;
+ private final SignalDelegate signal;
+
+ static jdk.internal.misc.Signal.Handler of(SignalDelegate signal, Handler handler) {
+ if (handler == Handler.SIG_DFL) {
+ return jdk.internal.misc.Signal.Handler.SIG_DFL;
+ } else if (handler == Handler.SIG_IGN) {
+ return jdk.internal.misc.Signal.Handler.SIG_IGN;
+ } else if (handler instanceof HandlerProxy) {
+ return ((HandlerProxy)handler).iHandler;
+ } else {
+ return new InternalMiscHandler(signal, handler);
+ }
+ }
+
+ private InternalMiscHandler(SignalDelegate signal, Handler handler) {
+ this.handler = handler;
+ this.signal = signal;
+ }
+
+ @Override
+ public void handle(jdk.internal.misc.Signal ignore) {
+ handler.handle(signal);
+ }
+ }
+}
--- /dev/null 2018-11-02 08:21:54.000000000 -0700
+++ new/src/java.base/share/classes/jdk/internal/unsupported/UnsafeForwarder.java 2018-11-02 08:21:53.000000000 -0700
@@ -0,0 +1,521 @@
+/*
+ * Copyright (c) 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.unsupported;
+
+import jdk.internal.misc.Unsafe;
+import jdk.internal.ref.Cleaner;
+import jdk.internal.vm.annotation.ForceInline;
+import sun.nio.ch.DirectBuffer;
+
+import java.lang.reflect.Field;
+
+public final class UnsafeForwarder {
+ private static final Unsafe UNSAFE = Unsafe.getUnsafe();
+ private static final UnsafeForwarder HELPER = new UnsafeForwarder();
+
+ private UnsafeForwarder() {
+ }
+
+ public static UnsafeForwarder getUnsafeHelper() {
+ return HELPER;
+ }
+
+ /// peek and poke operations
+ /// (compilers should optimize these to memory ops)
+ public int getInt(Object o, long offset) {
+ return UNSAFE.getInt(o, offset);
+ }
+
+ public void putInt(Object o, long offset, int x) {
+ UNSAFE.putInt(o, offset, x);
+ }
+
+ public Object getReference(Object o, long offset) {
+ return UNSAFE.getReference(o, offset);
+ }
+
+ public void putReference(Object o, long offset, Object x) {
+ UNSAFE.putReference(o, offset, x);
+ }
+
+ public boolean getBoolean(Object o, long offset) {
+ return UNSAFE.getBoolean(o, offset);
+ }
+
+ public void putBoolean(Object o, long offset, boolean x) {
+ UNSAFE.putBoolean(o, offset, x);
+ }
+
+ public byte getByte(Object o, long offset) {
+ return UNSAFE.getByte(o, offset);
+ }
+
+ public void putByte(Object o, long offset, byte x) {
+ UNSAFE.putByte(o, offset, x);
+ }
+
+ public short getShort(Object o, long offset) {
+ return UNSAFE.getShort(o, offset);
+ }
+
+ public void putShort(Object o, long offset, short x) {
+ UNSAFE.putShort(o, offset, x);
+ }
+
+ public char getChar(Object o, long offset) {
+ return UNSAFE.getChar(o, offset);
+ }
+
+ public void putChar(Object o, long offset, char x) {
+ UNSAFE.putChar(o, offset, x);
+ }
+
+ public long getLong(Object o, long offset) {
+ return UNSAFE.getLong(o, offset);
+ }
+
+ public void putLong(Object o, long offset, long x) {
+ UNSAFE.putLong(o, offset, x);
+ }
+
+ public float getFloat(Object o, long offset) {
+ return UNSAFE.getFloat(o, offset);
+ }
+
+ public void putFloat(Object o, long offset, float x) {
+ UNSAFE.putFloat(o, offset, x);
+ }
+
+ public double getDouble(Object o, long offset) {
+ return UNSAFE.getDouble(o, offset);
+ }
+
+ public void putDouble(Object o, long offset, double x) {
+ UNSAFE.putDouble(o, offset, x);
+ }
+
+ // These work on values in the C heap.
+
+ public byte getByte(long address) {
+ return UNSAFE.getByte(address);
+ }
+
+ public void putByte(long address, byte x) {
+ UNSAFE.putByte(address, x);
+ }
+
+ public short getShort(long address) {
+ return UNSAFE.getShort(address);
+ }
+
+ public void putShort(long address, short x) {
+ UNSAFE.putShort(address, x);
+ }
+
+ public char getChar(long address) {
+ return UNSAFE.getChar(address);
+ }
+
+ public void putChar(long address, char x) {
+ UNSAFE.putChar(address, x);
+ }
+
+ public int getInt(long address) {
+ return UNSAFE.getInt(address);
+ }
+
+ public void putInt(long address, int x) {
+ UNSAFE.putInt(address, x);
+ }
+
+ public long getLong(long address) {
+ return UNSAFE.getLong(address);
+ }
+
+ public void putLong(long address, long x) {
+ UNSAFE.putLong(address, x);
+ }
+
+ public float getFloat(long address) {
+ return UNSAFE.getFloat(address);
+ }
+
+ public void putFloat(long address, float x) {
+ UNSAFE.putFloat(address, x);
+ }
+
+ public double getDouble(long address) {
+ return UNSAFE.getDouble(address);
+ }
+
+ public void putDouble(long address, double x) {
+ UNSAFE.putDouble(address, x);
+ }
+
+ public long getAddress(long address) {
+ return UNSAFE.getAddress(address);
+ }
+
+ public void putAddress(long address, long x) {
+ UNSAFE.putAddress(address, x);
+ }
+
+ /// wrappers for malloc, realloc, free:
+
+ public long allocateMemory(long bytes) {
+ return UNSAFE.allocateMemory(bytes);
+ }
+
+ public long reallocateMemory(long address, long bytes) {
+ return UNSAFE.reallocateMemory(address, bytes);
+ }
+
+ public void setMemory(Object o, long offset, long bytes, byte value) {
+ UNSAFE.setMemory(o, offset, bytes, value);
+ }
+
+ public void setMemory(long address, long bytes, byte value) {
+ UNSAFE.setMemory(address, bytes, value);
+ }
+
+ public void copyMemory(Object srcBase, long srcOffset,
+ Object destBase, long destOffset,
+ long bytes) {
+ UNSAFE.copyMemory(srcBase, srcOffset, destBase, destOffset, bytes);
+ }
+
+ public void copyMemory(long srcAddress, long destAddress, long bytes) {
+ UNSAFE.copyMemory(srcAddress, destAddress, bytes);
+ }
+
+ public void freeMemory(long address) {
+ UNSAFE.freeMemory(address);
+ }
+
+ /// random queries
+
+ /**
+ * This constant differs from all results that will ever be returned from
+ * {@link #staticFieldOffset}, {@link #objectFieldOffset},
+ * or {@link #arrayBaseOffset}.
+ */
+ public static final int INVALID_FIELD_OFFSET = jdk.internal.misc.Unsafe.INVALID_FIELD_OFFSET;
+
+ public long objectFieldOffset(Field f) {
+ return UNSAFE.objectFieldOffset(f);
+ }
+
+ public long staticFieldOffset(Field f) {
+ return UNSAFE.staticFieldOffset(f);
+ }
+
+ public Object staticFieldBase(Field f) {
+ return UNSAFE.staticFieldBase(f);
+ }
+
+ public boolean shouldBeInitialized(Class> c) {
+ return UNSAFE.shouldBeInitialized(c);
+ }
+
+ public void ensureClassInitialized(Class> c) {
+ UNSAFE.ensureClassInitialized(c);
+ }
+
+ public int arrayBaseOffset(Class> arrayClass) {
+ return UNSAFE.arrayBaseOffset(arrayClass);
+ }
+
+ /**
+ * The value of {@code arrayBaseOffset(boolean[].class)}
+ */
+ public static final int ARRAY_BOOLEAN_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
+
+ /**
+ * The value of {@code arrayBaseOffset(byte[].class)}
+ */
+ public static final int ARRAY_BYTE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET;
+
+ /**
+ * The value of {@code arrayBaseOffset(short[].class)}
+ */
+ public static final int ARRAY_SHORT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_SHORT_BASE_OFFSET;
+
+ /**
+ * The value of {@code arrayBaseOffset(char[].class)}
+ */
+ public static final int ARRAY_CHAR_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_CHAR_BASE_OFFSET;
+
+ /**
+ * The value of {@code arrayBaseOffset(int[].class)}
+ */
+ public static final int ARRAY_INT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_INT_BASE_OFFSET;
+
+ /**
+ * The value of {@code arrayBaseOffset(long[].class)}
+ */
+ public static final int ARRAY_LONG_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_LONG_BASE_OFFSET;
+
+ /**
+ * The value of {@code arrayBaseOffset(float[].class)}
+ */
+ public static final int ARRAY_FLOAT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_FLOAT_BASE_OFFSET;
+
+ /**
+ * The value of {@code arrayBaseOffset(double[].class)}
+ */
+ public static final int ARRAY_DOUBLE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_DOUBLE_BASE_OFFSET;
+
+ /**
+ * The value of {@code arrayBaseOffset(Object[].class)}
+ */
+ public static final int ARRAY_OBJECT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_OBJECT_BASE_OFFSET;
+
+ public int arrayIndexScale(Class> arrayClass) {
+ return UNSAFE.arrayIndexScale(arrayClass);
+ }
+
+ public static final int ARRAY_BOOLEAN_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_INDEX_SCALE;
+
+ public static final int ARRAY_BYTE_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_BYTE_INDEX_SCALE;
+
+ public static final int ARRAY_SHORT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_SHORT_INDEX_SCALE;
+
+ public static final int ARRAY_CHAR_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_CHAR_INDEX_SCALE;
+
+ public static final int ARRAY_INT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_INT_INDEX_SCALE;
+
+ public static final int ARRAY_LONG_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_LONG_INDEX_SCALE;
+
+ public static final int ARRAY_FLOAT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_FLOAT_INDEX_SCALE;
+
+ public static final int ARRAY_DOUBLE_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_DOUBLE_INDEX_SCALE;
+
+ public static final int ARRAY_OBJECT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_OBJECT_INDEX_SCALE;
+
+ public int addressSize() {
+ return UNSAFE.addressSize();
+ }
+
+ /**
+ * The value of {@code addressSize()}
+ */
+ public static final int ADDRESS_SIZE = UNSAFE.addressSize();
+
+ public int pageSize() {
+ return UNSAFE.pageSize();
+ }
+
+
+ /// random trusted operations from JNI:
+ public Class> defineAnonymousClass(Class> hostClass, byte[] data, Object[] cpPatches) {
+ return UNSAFE.defineAnonymousClass(hostClass, data, cpPatches);
+ }
+
+ public Object allocateInstance(Class> cls)
+ throws InstantiationException {
+ return UNSAFE.allocateInstance(cls);
+ }
+
+ public void throwException(Throwable ee) {
+ UNSAFE.throwException(ee);
+ }
+
+ public final boolean compareAndSetReference(Object o, long offset,
+ Object expected,
+ Object x) {
+ return UNSAFE.compareAndSetReference(o, offset, expected, x);
+ }
+
+ public final boolean compareAndSetInt(Object o, long offset,
+ int expected,
+ int x) {
+ return UNSAFE.compareAndSetInt(o, offset, expected, x);
+ }
+
+ public final boolean compareAndSetLong(Object o, long offset,
+ long expected,
+ long x) {
+ return UNSAFE.compareAndSetLong(o, offset, expected, x);
+ }
+
+ public Object getReferenceVolatile(Object o, long offset) {
+ return UNSAFE.getReferenceVolatile(o, offset);
+ }
+
+ public void putReferenceVolatile(Object o, long offset, Object x) {
+ UNSAFE.putReferenceVolatile(o, offset, x);
+ }
+
+ public int getIntVolatile(Object o, long offset) {
+ return UNSAFE.getIntVolatile(o, offset);
+ }
+
+ public void putIntVolatile(Object o, long offset, int x) {
+ UNSAFE.putIntVolatile(o, offset, x);
+ }
+
+ public boolean getBooleanVolatile(Object o, long offset) {
+ return UNSAFE.getBooleanVolatile(o, offset);
+ }
+
+ public void putBooleanVolatile(Object o, long offset, boolean x) {
+ UNSAFE.putBooleanVolatile(o, offset, x);
+ }
+
+ public byte getByteVolatile(Object o, long offset) {
+ return UNSAFE.getByteVolatile(o, offset);
+ }
+
+ public void putByteVolatile(Object o, long offset, byte x) {
+ UNSAFE.putByteVolatile(o, offset, x);
+ }
+
+ public short getShortVolatile(Object o, long offset) {
+ return UNSAFE.getShortVolatile(o, offset);
+ }
+
+ public void putShortVolatile(Object o, long offset, short x) {
+ UNSAFE.putShortVolatile(o, offset, x);
+ }
+
+ public char getCharVolatile(Object o, long offset) {
+ return UNSAFE.getCharVolatile(o, offset);
+ }
+
+ public void putCharVolatile(Object o, long offset, char x) {
+ UNSAFE.putCharVolatile(o, offset, x);
+ }
+
+ public long getLongVolatile(Object o, long offset) {
+ return UNSAFE.getLongVolatile(o, offset);
+ }
+
+ public void putLongVolatile(Object o, long offset, long x) {
+ UNSAFE.putLongVolatile(o, offset, x);
+ }
+
+ public float getFloatVolatile(Object o, long offset) {
+ return UNSAFE.getFloatVolatile(o, offset);
+ }
+
+ public void putFloatVolatile(Object o, long offset, float x) {
+ UNSAFE.putFloatVolatile(o, offset, x);
+ }
+
+ public double getDoubleVolatile(Object o, long offset) {
+ return UNSAFE.getDoubleVolatile(o, offset);
+ }
+
+ public void putDoubleVolatile(Object o, long offset, double x) {
+ UNSAFE.putDoubleVolatile(o, offset, x);
+ }
+
+ public void putReferenceRelease(Object o, long offset, Object x) {
+ UNSAFE.putReferenceRelease(o, offset, x);
+ }
+
+ public void putIntRelease(Object o, long offset, int x) {
+ UNSAFE.putIntRelease(o, offset, x);
+ }
+
+ public void putLongRelease(Object o, long offset, long x) {
+ UNSAFE.putLongRelease(o, offset, x);
+ }
+
+ public void unpark(Object thread) {
+ UNSAFE.unpark(thread);
+ }
+
+ @ForceInline
+ public void park(boolean isAbsolute, long time) {
+ UNSAFE.park(isAbsolute, time);
+ }
+
+ @ForceInline
+ public final int getAndAddInt(Object o, long offset, int delta) {
+ return UNSAFE.getAndAddInt(o, offset, delta);
+ }
+
+ @ForceInline
+ public final long getAndAddLong(Object o, long offset, long delta) {
+ return UNSAFE.getAndAddLong(o, offset, delta);
+ }
+
+ @ForceInline
+ public final int getAndSetInt(Object o, long offset, int newValue) {
+ return UNSAFE.getAndSetInt(o, offset, newValue);
+ }
+
+ @ForceInline
+ public final long getAndSetLong(Object o, long offset, long newValue) {
+ return UNSAFE.getAndSetLong(o, offset, newValue);
+ }
+
+ @ForceInline
+ public final Object getAndSetReference(Object o, long offset, Object newValue) {
+ return UNSAFE.getAndSetReference(o, offset, newValue);
+ }
+
+ @ForceInline
+ public void loadFence() {
+ UNSAFE.loadFence();
+ }
+
+ @ForceInline
+ public void storeFence() {
+ UNSAFE.storeFence();
+ }
+
+ @ForceInline
+ public void fullFence() {
+ UNSAFE.fullFence();
+ }
+
+ /**
+ * Invokes the given direct byte buffer's cleaner, if any.
+ *
+ * @param directBuffer a direct byte buffer
+ * @throws NullPointerException if {@code directBuffer} is null
+ * @throws IllegalArgumentException if {@code directBuffer} is non-direct,
+ * or is a {@link java.nio.Buffer#slice slice}, or is a
+ * {@link java.nio.Buffer#duplicate duplicate}
+ * @since 9
+ */
+ public void invokeCleaner(java.nio.ByteBuffer directBuffer) {
+ if (!directBuffer.isDirect())
+ throw new IllegalArgumentException("buffer is non-direct");
+
+ DirectBuffer db = (DirectBuffer) directBuffer;
+ if (db.attachment() != null)
+ throw new IllegalArgumentException("duplicate or slice");
+
+ Cleaner cleaner = db.cleaner();
+ if (cleaner != null) {
+ cleaner.clean();
+ }
+ }
+}
+