--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/NativeThread.patch Wed Apr 03 10:47:10 2019 +0100
@@ -0,0 +1,138 @@
+diff -r 7d5a4a48e876 src/java.base/share/classes/java/lang/System.java
+--- a/src/java.base/share/classes/java/lang/System.java Wed Mar 27 14:40:36 2019 -0700
++++ b/src/java.base/share/classes/java/lang/System.java Wed Apr 03 09:46:50 2019 +0100
+@@ -2172,6 +2172,12 @@
+ public void blockedOn(Interruptible b) {
+ Thread.blockedOn(b);
+ }
++ public void setNativeTid(long tid) {
++ Thread.setNativeTid(tid);
++ }
++ public long nativeTid() {
++ return Thread.nativeTid();
++ }
+ public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
+ Shutdown.add(slot, registerShutdownInProgress, hook);
+ }
+diff -r 7d5a4a48e876 src/java.base/share/classes/java/lang/Thread.java
+--- a/src/java.base/share/classes/java/lang/Thread.java Wed Mar 27 14:40:36 2019 -0700
++++ b/src/java.base/share/classes/java/lang/Thread.java Wed Apr 03 09:46:50 2019 +0100
+@@ -241,6 +241,18 @@
+ }
+
+ /**
++ * Native thread id, cached here for use for threads are blocked in I/O
++ * operations.
++ */
++ private long nativeTid;
++ static void setNativeTid(long tid) {
++ Thread.currentThread().nativeTid = tid;
++ }
++ static long nativeTid() {
++ return Thread.currentThread().nativeTid;
++ }
++
++ /**
+ * The minimum priority that a thread can have.
+ */
+ public static final int MIN_PRIORITY = 1;
+diff -r 7d5a4a48e876 src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java
+--- a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java Wed Mar 27 14:40:36 2019 -0700
++++ b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java Wed Apr 03 09:46:50 2019 +0100
+@@ -107,6 +107,16 @@
+ void blockedOn(Interruptible b);
+
+ /**
++ * Set the current thread's native ID
++ */
++ void setNativeTid(long tid);
++
++ /**
++ * Returns the current thread's native ID
++ */
++ long nativeTid();
++
++ /**
+ * Registers a shutdown hook.
+ *
+ * It is expected that this method with registerShutdownInProgress=true
+diff -r 7d5a4a48e876 src/java.base/unix/classes/sun/nio/ch/NativeThread.java
+--- a/src/java.base/unix/classes/sun/nio/ch/NativeThread.java Wed Mar 27 14:40:36 2019 -0700
++++ b/src/java.base/unix/classes/sun/nio/ch/NativeThread.java Wed Apr 03 09:46:50 2019 +0100
+@@ -25,7 +25,6 @@
+
+ package sun.nio.ch;
+
+-
+ // Signalling operations on native threads
+ //
+ // On some operating systems (e.g., Linux), closing a channel while another
+@@ -33,23 +32,35 @@
+ // thread to be released. This class provides access to the native threads
+ // upon which Java threads are built, and defines a simple signal mechanism
+ // that can be used to release a native thread from a blocking I/O operation.
+-// On systems that do not require this type of signalling, the current() method
+-// always returns -1 and the signal(long) method has no effect.
+
++import jdk.internal.access.JavaLangAccess;
++import jdk.internal.access.SharedSecrets;
+
+ public class NativeThread {
++ private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
+
+- // Returns an opaque token representing the native thread underlying the
+- // invoking Java thread. On systems that do not require signalling, this
+- // method always returns -1.
+- //
+- public static native long current();
++ /**
++ * Returns the current thread's ID.
++ */
++ public static long current() {
++ long tid = JLA.nativeTid();
++ if (tid == 0) {
++ tid = current0();
++ JLA.setNativeTid(tid);
++ }
++ return tid;
++ }
+
+- // Signals the given native thread so as to release it from a blocking I/O
+- // operation. On systems that do not require signalling, this method has
+- // no effect.
+- //
+- public static native void signal(long nt);
++ /**
++ * Signals the given thread.
++ */
++ public static void signal(long tid) {
++ signal0(tid);
++ }
++
++ private static native long current0();
++
++ private static native void signal0(long tid);
+
+ private static native void init();
+
+diff -r 7d5a4a48e876 src/java.base/unix/native/libnio/ch/NativeThread.c
+--- a/src/java.base/unix/native/libnio/ch/NativeThread.c Wed Mar 27 14:40:36 2019 -0700
++++ b/src/java.base/unix/native/libnio/ch/NativeThread.c Wed Apr 03 09:46:50 2019 +0100
+@@ -77,7 +77,7 @@
+ }
+
+ JNIEXPORT jlong JNICALL
+-Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl)
++Java_sun_nio_ch_NativeThread_current0(JNIEnv *env, jclass cl)
+ {
+ #ifdef __solaris__
+ return (jlong)thr_self();
+@@ -87,7 +87,7 @@
+ }
+
+ JNIEXPORT void JNICALL
+-Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread)
++Java_sun_nio_ch_NativeThread_signal0(JNIEnv *env, jclass cl, jlong thread)
+ {
+ int ret;
+ #ifdef __solaris__
--- a/src/java.base/share/classes/java/lang/System.java Tue Apr 02 14:36:17 2019 +0100
+++ b/src/java.base/share/classes/java/lang/System.java Wed Apr 03 10:47:10 2019 +0100
@@ -2172,12 +2172,6 @@
public void blockedOn(Interruptible b) {
Thread.blockedOn(b);
}
- public void setNativeTid(long tid) {
- Thread.setNativeTid(tid);
- }
- public long nativeTid() {
- return Thread.nativeTid();
- }
public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
Shutdown.add(slot, registerShutdownInProgress, hook);
}
--- a/src/java.base/share/classes/java/lang/Thread.java Tue Apr 02 14:36:17 2019 +0100
+++ b/src/java.base/share/classes/java/lang/Thread.java Wed Apr 03 10:47:10 2019 +0100
@@ -241,18 +241,6 @@
}
/**
- * Native thread id, cached here for use for threads are blocked in I/O
- * operations.
- */
- private long nativeTid;
- static void setNativeTid(long tid) {
- Thread.currentThread().nativeTid = tid;
- }
- static long nativeTid() {
- return Thread.currentThread().nativeTid;
- }
-
- /**
* The minimum priority that a thread can have.
*/
public static final int MIN_PRIORITY = 1;
--- a/src/java.base/share/classes/java/net/SocketImpl.java Tue Apr 02 14:36:17 2019 +0100
+++ b/src/java.base/share/classes/java/net/SocketImpl.java Wed Apr 03 10:47:10 2019 +0100
@@ -43,16 +43,16 @@
* create both client and server sockets.
*
* @implNote The JDK historically used a {@code SocketImpl} implementation named
- * <em>PlainSocketImpl</em>. This has been replaced by a simpler and more modern
- * implementation but the JDK continues to ship with the older implementation
- * to allow code that depends on unspecified behavior, that differs between the
- * old and new implementations, to continue to run. The old implementation
- * will be used if the Java virtual machine is started with the system property
- * {@systemProperty jdk.net.usePlainSocketImpl} set on the command line. The
- * value of the system property is a boolean. If set without a value then it
- * defaults to {@code true}, hence running with {@code -Djdk.net.usePlainSocketImpl}
- * or {@code -Djdk.net.usePlainSocketImpl=true} will configure the Java virtual
- * machine use the old implementation.
+ * <em>PlainSocketImpl</em>. This has been replaced by a newer implementation
+ * but the JDK continues to ship with the older implementation to allow code that
+ * depends on unspecified behavior, that differs between the old and new
+ * implementations, to continue to run. The old implementation will be used if
+ * the Java virtual machine is started with the system property {@systemProperty
+ * jdk.net.usePlainSocketImpl} set on the command line. The value of the system
+ * property is the string representation of a boolean. If set without a value
+ * then it defaults to {@code true}, hence running with {@code
+ * -Djdk.net.usePlainSocketImpl} or {@code -Djdk.net.usePlainSocketImpl=true}
+ * will configure the Java virtual machine use the old implementation.
*
* @author unascribed
* @since 1.0
--- a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java Tue Apr 02 14:36:17 2019 +0100
+++ b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java Wed Apr 03 10:47:10 2019 +0100
@@ -107,16 +107,6 @@
void blockedOn(Interruptible b);
/**
- * Set the current thread's native ID
- */
- void setNativeTid(long tid);
-
- /**
- * Returns the current thread's native ID
- */
- long nativeTid();
-
- /**
* Registers a shutdown hook.
*
* It is expected that this method with registerShutdownInProgress=true
--- a/src/java.base/unix/classes/sun/nio/ch/NativeThread.java Tue Apr 02 14:36:17 2019 +0100
+++ b/src/java.base/unix/classes/sun/nio/ch/NativeThread.java Wed Apr 03 10:47:10 2019 +0100
@@ -25,6 +25,7 @@
package sun.nio.ch;
+
// Signalling operations on native threads
//
// On some operating systems (e.g., Linux), closing a channel while another
@@ -32,35 +33,23 @@
// thread to be released. This class provides access to the native threads
// upon which Java threads are built, and defines a simple signal mechanism
// that can be used to release a native thread from a blocking I/O operation.
+// On systems that do not require this type of signalling, the current() method
+// always returns -1 and the signal(long) method has no effect.
-import jdk.internal.access.JavaLangAccess;
-import jdk.internal.access.SharedSecrets;
public class NativeThread {
- private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
- /**
- * Returns the current thread's ID.
- */
- public static long current() {
- long tid = JLA.nativeTid();
- if (tid == 0) {
- tid = current0();
- JLA.setNativeTid(tid);
- }
- return tid;
- }
+ // Returns an opaque token representing the native thread underlying the
+ // invoking Java thread. On systems that do not require signalling, this
+ // method always returns -1.
+ //
+ public static native long current();
- /**
- * Signals the given thread.
- */
- public static void signal(long tid) {
- signal0(tid);
- }
-
- private static native long current0();
-
- private static native void signal0(long tid);
+ // Signals the given native thread so as to release it from a blocking I/O
+ // operation. On systems that do not require signalling, this method has
+ // no effect.
+ //
+ public static native void signal(long nt);
private static native void init();
--- a/src/java.base/unix/native/libnio/ch/NativeThread.c Tue Apr 02 14:36:17 2019 +0100
+++ b/src/java.base/unix/native/libnio/ch/NativeThread.c Wed Apr 03 10:47:10 2019 +0100
@@ -77,7 +77,7 @@
}
JNIEXPORT jlong JNICALL
-Java_sun_nio_ch_NativeThread_current0(JNIEnv *env, jclass cl)
+Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl)
{
#ifdef __solaris__
return (jlong)thr_self();
@@ -87,7 +87,7 @@
}
JNIEXPORT void JNICALL
-Java_sun_nio_ch_NativeThread_signal0(JNIEnv *env, jclass cl, jlong thread)
+Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread)
{
int ret;
#ifdef __solaris__