diff --git a/closed/adds/jdk/src/share/native/sun/nio/ch/nio_util.c b/closed/adds/jdk/src/share/native/sun/nio/ch/nio_util.c
new file mode 100644
index 00000000000..a19e8717bc4
--- /dev/null
+++ b/closed/adds/jdk/src/share/native/sun/nio/ch/nio_util.c
@@ -0,0 +1,38 @@
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ *
+ * 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.
+ *
+ * IBM designates this particular file as subject to the "Classpath" exception
+ * as provided by IBM 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, see .
+ *
+ * ===========================================================================
+ */
+
+#include "jni.h"
+
+#include "j9access.h"
+/* tracehelp.c defines getTraceInterfaceFromVM(), used by J9_UTINTERFACE_FROM_VM(). */
+#include "tracehelp.c"
+#include "ut_jcl_nio.c"
+
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+ UT_JCL_NIO_MODULE_LOADED(J9_UTINTERFACE_FROM_VM((J9JavaVM *)vm));
+
+ return JNI_VERSION_1_2;
+}
diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk
index 933e68e21b7..8fcae4774d3 100644
--- a/jdk/make/lib/CoreLibraries.gmk
+++ b/jdk/make/lib/CoreLibraries.gmk
@@ -24,7 +24,7 @@
#
# ===========================================================================
-# (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
+# (c) Copyright IBM Corp. 2023, 2025 All Rights Reserved
# ===========================================================================
# Include custom extensions if available.
@@ -152,6 +152,21 @@ LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/l
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/util
+BUILD_LIBJAVA_check_version.c_CFLAGS := \
+ -I$(OPENJ9_TOPDIR)/runtime/include \
+ -I$(OPENJ9_TOPDIR)/runtime/oti \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR) \
+ -I$(OPENJ9_TOPDIR)/runtime/jcl \
+ -I$(OPENJ9_TOPDIR)/runtime/util \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBJAVA_io_util_md.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBJAVA_UnixFileSystem_md.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+
ifeq ($(OPENJDK_TARGET_OS), windows)
LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/util/locale/provider
else ifeq ($(OPENJDK_TARGET_OS), macosx)
diff --git a/jdk/make/lib/NetworkingLibraries.gmk b/jdk/make/lib/NetworkingLibraries.gmk
index 347c3237630..6d9c0eb957f 100644
--- a/jdk/make/lib/NetworkingLibraries.gmk
+++ b/jdk/make/lib/NetworkingLibraries.gmk
@@ -23,6 +23,10 @@
# questions.
#
+# ===========================================================================
+# (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+# ===========================================================================
+
LIBNET_SRC_DIRS := $(JDK_TOPDIR)/src/share/native/java/net \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/net \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/net/ \
@@ -37,6 +41,33 @@ endif
LIBNET_CFLAGS := $(foreach dir, $(LIBNET_SRC_DIRS), -I$(dir))
+BUILD_LIBNET_aix_close.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBNET_bsd_close.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBNET_DualStackPlainSocketImpl.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBNET_linux_close.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBNET_net_util.c_CFLAGS := \
+ -I$(OPENJ9_TOPDIR)/runtime/include \
+ -I$(OPENJ9_TOPDIR)/runtime/oti \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR) \
+ -I$(OPENJ9_TOPDIR)/runtime/jcl \
+ -I$(OPENJ9_TOPDIR)/runtime/util \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBNET_PlainSocketImpl.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBNET_TwoStacksPlainSocketImpl.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+
LIBNET_EXCLUDE_FILES :=
ifneq ($(OPENJDK_TARGET_OS), linux)
LIBNET_EXCLUDE_FILES += linux_close.c
diff --git a/jdk/make/lib/NioLibraries.gmk b/jdk/make/lib/NioLibraries.gmk
index 6c9c46a3f3d..bb130d151f6 100644
--- a/jdk/make/lib/NioLibraries.gmk
+++ b/jdk/make/lib/NioLibraries.gmk
@@ -23,8 +23,13 @@
# questions.
#
+# ===========================================================================
+# (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+# ===========================================================================
+
BUILD_LIBNIO_SRC := \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/nio \
+ $(SRC_ROOT)/closed/adds/jdk/src/share/native/sun/nio/ch \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/ch \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/fs
@@ -34,6 +39,24 @@ BUILD_LIBNIO_CFLAGS := \
-I$(JDK_TOPDIR)/src/share/native/java/net \
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/net
+BUILD_LIBNIO_FileDispatcherImpl.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBNIO_Net.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBNIO_nio_util.c_CFLAGS := \
+ -I$(OPENJ9_TOPDIR)/runtime/include \
+ -I$(OPENJ9_TOPDIR)/runtime/oti \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR) \
+ -I$(OPENJ9_TOPDIR)/runtime/jcl \
+ -I$(OPENJ9_TOPDIR)/runtime/util \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+BUILD_LIBNIO_SocketDispatcher.c_CFLAGS := \
+ -I$(OPENJ9OMR_TOPDIR)/include_core \
+ -I$(OPENJ9_VM_BUILD_DIR)/jcl
+
BUILD_LIBNIO_FILES := \
DatagramChannelImpl.c \
DatagramDispatcher.c \
@@ -43,6 +66,7 @@ BUILD_LIBNIO_FILES := \
IOUtil.c \
MappedByteBuffer.c \
Net.c \
+ nio_util.c \
ServerSocketChannelImpl.c \
SocketChannelImpl.c \
SocketDispatcher.c
diff --git a/jdk/make/mapfiles/libnio/mapfile-linux b/jdk/make/mapfiles/libnio/mapfile-linux
index bdfaa45f13f..337fa49caf5 100644
--- a/jdk/make/mapfiles/libnio/mapfile-linux
+++ b/jdk/make/mapfiles/libnio/mapfile-linux
@@ -23,6 +23,10 @@
# questions.
#
+# ===========================================================================
+# (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+# ===========================================================================
+
SUNWprivate_1.1 {
global:
Java_java_nio_MappedByteBuffer_force0;
@@ -203,6 +207,7 @@ SUNWprivate_1.1 {
Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
Java_sun_nio_fs_UnixCopyFile_transfer;
+ JNI_OnLoad;
handleSocketError;
local:
diff --git a/jdk/make/mapfiles/libnio/mapfile-macosx b/jdk/make/mapfiles/libnio/mapfile-macosx
index ac8a572d123..afcb13a1375 100644
--- a/jdk/make/mapfiles/libnio/mapfile-macosx
+++ b/jdk/make/mapfiles/libnio/mapfile-macosx
@@ -23,6 +23,10 @@
# questions.
#
+# ===========================================================================
+# (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+# ===========================================================================
+
SUNWprivate_1.1 {
global:
Java_java_nio_MappedByteBuffer_force0;
@@ -175,6 +179,7 @@ SUNWprivate_1.1 {
Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
Java_sun_nio_fs_UnixCopyFile_transfer;
+ JNI_OnLoad;
handleSocketError;
local:
diff --git a/jdk/src/aix/native/java/net/aix_close.c b/jdk/src/aix/native/java/net/aix_close.c
index 90d57b42f07..64aa18ba72b 100644
--- a/jdk/src/aix/native/java/net/aix_close.c
+++ b/jdk/src/aix/native/java/net/aix_close.c
@@ -24,6 +24,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
/*
* This file contains implementations of NET_... functions. The NET_.. functions are
* wrappers for common file- and socket functions plus provisions for non-blocking IO.
@@ -55,6 +61,9 @@
#include
#include
+#include
+
+#include "ut_jcl_net.h"
/*
* Stack allocated by thread when doing blocking operation
@@ -370,6 +379,7 @@ int NET_Dup2(int fd, int fd2) {
* preempted and the I/O system call will return -1/EBADF.
*/
int NET_SocketClose(int fd) {
+ Trc_NET_SocketClose(fd);
return closefd(-1, fd);
}
@@ -444,6 +454,16 @@ int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
return -1;
}
+ if (AF_INET == addr->sa_family) {
+ char buf[INET_ADDRSTRLEN];
+ struct sockaddr_in *sa = (struct sockaddr_in *)addr;
+ Trc_NET_Connect4(s, inet_ntop(AF_INET, &sa->sin_addr, buf, sizeof(buf)), ntohs(sa->sin_port), addrlen);
+ } else if (AF_INET6 == addr->sa_family) {
+ char buf[INET6_ADDRSTRLEN];
+ struct sockaddr_in6 *sa = (struct sockaddr_in6 *)addr;
+ Trc_NET_Connect6(s, inet_ntop(AF_INET6, &sa->sin6_addr, buf, sizeof(buf)), ntohs(sa->sin6_port), ntohl(sa->sin6_scope_id), addrlen);
+ }
+
/* On AIX, when the system call connect() is interrupted, the connection
* is not aborted and it will be established asynchronously by the kernel.
* Hence, no need to restart connect() when EINTR is received
diff --git a/jdk/src/share/native/common/check_version.c b/jdk/src/share/native/common/check_version.c
index b0dd5f859b3..9cc0cb86cd2 100644
--- a/jdk/src/share/native/common/check_version.c
+++ b/jdk/src/share/native/common/check_version.c
@@ -24,13 +24,18 @@
*/
/*
* ===========================================================================
- * (c) Copyright IBM Corp. 2024, 2024 All Rights Reserved
+ * (c) Copyright IBM Corp. 2024, 2025 All Rights Reserved
* ===========================================================================
*/
#include "jni.h"
#include "jvm.h"
+#include "j9access.h"
+/* tracehelp.c defines getTraceInterfaceFromVM(), used by J9_UTINTERFACE_FROM_VM(). */
+#include "tracehelp.c"
+#include "ut_jcl_java.c"
+
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved)
{
@@ -45,5 +50,8 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
(*env)->FatalError(env, buf);
}
}
+
+ UT_JCL_JAVA_MODULE_LOADED(J9_UTINTERFACE_FROM_VM((J9JavaVM *)vm));
+
return JNI_VERSION_1_2;
}
diff --git a/jdk/src/share/native/java/net/net_util.c b/jdk/src/share/native/java/net/net_util.c
index b1b8223a633..ef78faff1a5 100644
--- a/jdk/src/share/native/java/net/net_util.c
+++ b/jdk/src/share/native/java/net/net_util.c
@@ -23,11 +23,22 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include "jni.h"
#include "jvm.h"
#include "jni_util.h"
#include "net_util.h"
+#include "j9access.h"
+/* tracehelp.c defines getTraceInterfaceFromVM(), used by J9_UTINTERFACE_FROM_VM(). */
+#include "tracehelp.c"
+#include "ut_jcl_net.c"
+
int IPv6_supported() ;
static int IPv6_available;
@@ -53,6 +64,9 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
return JNI_VERSION_1_2;
}
}
+
+ UT_JCL_NET_MODULE_LOADED(J9_UTINTERFACE_FROM_VM((J9JavaVM *)vm));
+
iCls = (*env)->FindClass(env, "java/lang/Boolean");
CHECK_NULL_RETURN(iCls, JNI_VERSION_1_2);
mid = (*env)->GetStaticMethodID(env, iCls, "getBoolean", "(Ljava/lang/String;)Z");
diff --git a/jdk/src/solaris/native/java/io/UnixFileSystem_md.c b/jdk/src/solaris/native/java/io/UnixFileSystem_md.c
index 225e23f8dd6..af0efa3659f 100644
--- a/jdk/src/solaris/native/java/io/UnixFileSystem_md.c
+++ b/jdk/src/solaris/native/java/io/UnixFileSystem_md.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include
#include
#include
@@ -42,6 +48,8 @@
#include "java_io_FileSystem.h"
#include "java_io_UnixFileSystem.h"
+#include "ut_jcl_java.h"
+
#if defined(_ALLBSD_SOURCE)
#define dirent64 dirent
#define readdir64_r readdir_r
@@ -255,6 +263,7 @@ Java_java_io_UnixFileSystem_createFileExclusively(JNIEnv *env, jclass cls,
if (errno != EEXIST)
JNU_ThrowIOExceptionWithLastError(env, path);
} else {
+ Trc_io_UnixFileSystem_createFileExclusively_close(fd);
if (close(fd) == -1)
JNU_ThrowIOExceptionWithLastError(env, path);
rv = JNI_TRUE;
diff --git a/jdk/src/solaris/native/java/io/io_util_md.c b/jdk/src/solaris/native/java/io/io_util_md.c
index 0dee96b8902..a0f76e9703b 100644
--- a/jdk/src/solaris/native/java/io/io_util_md.c
+++ b/jdk/src/solaris/native/java/io/io_util_md.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#if defined(__linux__)
#define _FILE_OFFSET_BITS 64
#endif
@@ -43,6 +49,8 @@
#include
#endif
+#include "ut_jcl_java.h"
+
#ifdef MACOSX
#include
@@ -94,6 +102,11 @@ handleOpen(const char *path, int oflag, int mode) {
fd = -1;
}
}
+ if (-1 == fd) {
+ Trc_io_handleOpen_err(path, oflag, mode, 0, 0, errno);
+ } else {
+ Trc_io_handleOpen(path, oflag, mode, 0, 0, (jlong)fd);
+ }
return fd;
}
@@ -148,8 +161,12 @@ fileClose(JNIEnv *env, jobject this, jfieldID fid)
dup2(devnull, fd);
close(devnull);
}
+ Trc_io_fileDescriptorClose((jlong)fd);
} else if (close(fd) == -1) {
+ Trc_io_fileDescriptorClose_err((jlong)fd, errno);
JNU_ThrowIOExceptionWithLastError(env, "close failed");
+ } else {
+ Trc_io_fileDescriptorClose((jlong)fd);
}
}
diff --git a/jdk/src/solaris/native/java/net/PlainSocketImpl.c b/jdk/src/solaris/native/java/net/PlainSocketImpl.c
index 373c5e36255..3d0dc4572d7 100644
--- a/jdk/src/solaris/native/java/net/PlainSocketImpl.c
+++ b/jdk/src/solaris/native/java/net/PlainSocketImpl.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include
#include
#include
@@ -36,6 +42,7 @@
#include
#endif
#include
+#include
#include
#ifdef __solaris__
@@ -52,6 +59,8 @@
#include "java_net_SocketOptions.h"
#include "java_net_PlainSocketImpl.h"
+#include "ut_jcl_net.h"
+
/************************************************************************
* PlainSocketImpl
*/
@@ -363,6 +372,14 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
*/
SET_NONBLOCKING(fd);
+ if (AF_INET == him.him4.sin_family) {
+ char buf[INET_ADDRSTRLEN];
+ Trc_PlainSocketImpl_socketConnect4("", fd, inet_ntop(AF_INET, &him.him4.sin_addr, buf, sizeof(buf)), port, len);
+ } else if (AF_INET6 == him.him6.sin6_family) {
+ char buf[INET6_ADDRSTRLEN];
+ Trc_PlainSocketImpl_socketConnect6("", fd, inet_ntop(AF_INET6, &him.him6.sin6_addr, buf, sizeof(buf)), port, ntohl(him.him6.sin6_scope_id), len);
+ }
+
/* no need to use NET_Connect as non-blocking */
connect_rv = connect(fd, (struct sockaddr *)&him, len);
diff --git a/jdk/src/solaris/native/java/net/bsd_close.c b/jdk/src/solaris/native/java/net/bsd_close.c
index 89a20707c40..fcfc2484350 100644
--- a/jdk/src/solaris/native/java/net/bsd_close.c
+++ b/jdk/src/solaris/native/java/net/bsd_close.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include
#include
#include
@@ -39,6 +45,9 @@
#include
#include
#include
+#include
+
+#include "ut_jcl_net.h"
/*
* Stack allocated by thread when doing blocking operation
@@ -341,6 +350,7 @@ int NET_Dup2(int fd, int fd2) {
* preempted and the I/O system call will return -1/EBADF.
*/
int NET_SocketClose(int fd) {
+ Trc_NET_SocketClose(fd);
return closefd(-1, fd);
}
@@ -407,6 +417,15 @@ int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
}
int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
+ if (AF_INET == addr->sa_family) {
+ char buf[INET_ADDRSTRLEN];
+ struct sockaddr_in *sa = (struct sockaddr_in *)addr;
+ Trc_NET_Connect4(s, inet_ntop(AF_INET, &sa->sin_addr, buf, sizeof(buf)), ntohs(sa->sin_port), addrlen);
+ } else if (AF_INET6 == addr->sa_family) {
+ char buf[INET6_ADDRSTRLEN];
+ struct sockaddr_in6 *sa = (struct sockaddr_in6 *)addr;
+ Trc_NET_Connect6(s, inet_ntop(AF_INET6, &sa->sin6_addr, buf, sizeof(buf)), ntohs(sa->sin6_port), ntohl(sa->sin6_scope_id), addrlen);
+ }
BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
}
diff --git a/jdk/src/solaris/native/java/net/linux_close.c b/jdk/src/solaris/native/java/net/linux_close.c
index f4c53a0d012..c53f6a06783 100644
--- a/jdk/src/solaris/native/java/net/linux_close.c
+++ b/jdk/src/solaris/native/java/net/linux_close.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include
#include
#include
@@ -37,6 +43,9 @@
#include
#include
#include
+#include
+
+#include "ut_jcl_net.h"
/*
* Stack allocated by thread when doing blocking operation
@@ -337,6 +346,7 @@ int NET_Dup2(int fd, int fd2) {
* preempted and the I/O system call will return -1/EBADF.
*/
int NET_SocketClose(int fd) {
+ Trc_NET_SocketClose(fd);
return closefd(-1, fd);
}
@@ -402,6 +412,15 @@ int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
}
int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
+ if (AF_INET == addr->sa_family) {
+ char buf[INET_ADDRSTRLEN];
+ struct sockaddr_in *sa = (struct sockaddr_in *)addr;
+ Trc_NET_Connect4(s, inet_ntop(AF_INET, &sa->sin_addr, buf, sizeof(buf)), ntohs(sa->sin_port), addrlen);
+ } else if (AF_INET6 == addr->sa_family) {
+ char buf[INET6_ADDRSTRLEN];
+ struct sockaddr_in6 *sa = (struct sockaddr_in6 *)addr;
+ Trc_NET_Connect6(s, inet_ntop(AF_INET6, &sa->sin6_addr, buf, sizeof(buf)), ntohs(sa->sin6_port), ntohl(sa->sin6_scope_id), addrlen);
+ }
BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
}
diff --git a/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c b/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
index 9b3ff8194ef..48707a60575 100644
--- a/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
+++ b/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#if defined(__linux__)
#define _FILE_OFFSET_BITS 64
#endif
@@ -63,6 +69,8 @@
#include "sun_nio_ch_FileDispatcherImpl.h"
#include "java_lang_Long.h"
+#include "ut_jcl_nio.h"
+
static int preCloseFD = -1; /* File descriptor to which we dup other fd's
before closing them for real */
@@ -284,6 +292,7 @@ Java_sun_nio_ch_FileDispatcherImpl_release0(JNIEnv *env, jobject this,
static void closeFileDescriptor(JNIEnv *env, int fd) {
if (fd != -1) {
+ Trc_nio_ch_FileDispatcherImpl_close(fd);
int result = close(fd);
if (result < 0)
JNU_ThrowIOExceptionWithLastError(env, "Close failed");
diff --git a/jdk/src/solaris/native/sun/nio/ch/Net.c b/jdk/src/solaris/native/sun/nio/ch/Net.c
index fcb6197c1d3..fffa56d21fa 100644
--- a/jdk/src/solaris/native/sun/nio/ch/Net.c
+++ b/jdk/src/solaris/native/sun/nio/ch/Net.c
@@ -23,12 +23,20 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
+#include
#include
#include
#include
#include
#include
#include
+#include
#include "jni.h"
#include "jni_util.h"
@@ -45,6 +53,8 @@
#include
#endif
+#include "ut_jcl_nio.h"
+
/**
* IP_MULTICAST_ALL supported since 2.6.31 but may not be available at
* build time.
@@ -337,6 +347,7 @@ Java_sun_nio_ch_Net_connect0(JNIEnv *env, jclass clazz, jboolean preferIPv6,
SOCKADDR sa;
int sa_len = SOCKADDR_LEN;
int rv;
+ int fd;
if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
&sa_len, preferIPv6) != 0)
@@ -344,7 +355,16 @@ Java_sun_nio_ch_Net_connect0(JNIEnv *env, jclass clazz, jboolean preferIPv6,
return IOS_THROWN;
}
- rv = connect(fdval(env, fdo), (struct sockaddr *)&sa, sa_len);
+ fd = fdval(env, fdo);
+ if (AF_INET == sa.him4.sin_family) {
+ char buf[INET_ADDRSTRLEN];
+ Trc_nio_ch_Net_connect4((jlong)fd, inet_ntop(AF_INET, &sa.him4.sin_addr, buf, sizeof(buf)), port, sa_len);
+ } else if (AF_INET6 == sa.him6.sin6_family) {
+ char buf[INET6_ADDRSTRLEN];
+ Trc_nio_ch_Net_connect6((jlong)fd, inet_ntop(AF_INET6, &sa.him6.sin6_addr, buf, sizeof(buf)), port, ntohl(sa.him6.sin6_scope_id), sa_len);
+ }
+
+ rv = connect(fd, (struct sockaddr *)&sa, sa_len);
if (rv != 0) {
if (errno == EINPROGRESS) {
return IOS_UNAVAILABLE;
diff --git a/jdk/src/windows/native/java/io/io_util_md.c b/jdk/src/windows/native/java/io/io_util_md.c
index 03a2bcbc49b..2e354a1ef82 100644
--- a/jdk/src/windows/native/java/io/io_util_md.c
+++ b/jdk/src/windows/native/java/io/io_util_md.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include "jni.h"
#include "jni_util.h"
#include "jvm.h"
@@ -41,6 +47,7 @@
#include
#include
+#include "ut_jcl_java.h"
static DWORD MAX_INPUT_EVENTS = 2000;
@@ -247,12 +254,22 @@ winFileHandleOpen(JNIEnv *env, jstring path, int flags)
FILE_ATTRIBUTE_NORMAL;
const DWORD flagsAndAttributes = maybeWriteThrough | maybeDeleteOnClose;
HANDLE h = NULL;
+ char *pathStr = NULL;
WCHAR *pathbuf = pathToNTPath(env, path, JNI_TRUE);
if (pathbuf == NULL) {
/* Exception already pending */
return -1;
}
+
+ if (TrcEnabled_Trc_io_handleOpen) {
+ int length = WideCharToMultiByte(CP_UTF8, 0, pathbuf, -1, NULL, 0, NULL, NULL);
+ pathStr = malloc(length);
+ if (NULL != pathStr) {
+ WideCharToMultiByte(CP_UTF8, 0, pathbuf, -1, pathStr, length, NULL, NULL);
+ }
+ }
+
h = CreateFileW(
pathbuf, /* Wide char path name */
access, /* Read and/or write permission */
@@ -264,9 +281,13 @@ winFileHandleOpen(JNIEnv *env, jstring path, int flags)
free(pathbuf);
if (h == INVALID_HANDLE_VALUE) {
+ Trc_io_handleOpen_err(pathStr, access, sharing, disposition, flagsAndAttributes, GetLastError());
+ free(pathStr);
throwFileNotFoundException(env, path);
return -1;
}
+ Trc_io_handleOpen(pathStr, access, sharing, disposition, flagsAndAttributes, (jlong)h);
+ free(pathStr);
return (jlong) h;
}
@@ -546,7 +567,10 @@ handleClose(JNIEnv *env, jobject this, jfieldID fid)
SET_FD(this, -1, fid);
if (CloseHandle(h) == 0) { /* Returns zero on failure */
+ Trc_io_fileDescriptorClose_err((jlong)fd, GetLastError());
JNU_ThrowIOExceptionWithLastError(env, "close failed");
+ } else {
+ Trc_io_fileDescriptorClose((jlong)fd);
}
return 0;
}
diff --git a/jdk/src/windows/native/java/net/DualStackPlainSocketImpl.c b/jdk/src/windows/native/java/net/DualStackPlainSocketImpl.c
index 6d4905d05df..a25e3059c53 100644
--- a/jdk/src/windows/native/java/net/DualStackPlainSocketImpl.c
+++ b/jdk/src/windows/native/java/net/DualStackPlainSocketImpl.c
@@ -22,12 +22,21 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include
#include
#include "jni.h"
#include "net_util.h"
#include "java_net_DualStackPlainSocketImpl.h"
+#include "ut_jcl_net.h"
+
#define SET_BLOCKING 0
#define SET_NONBLOCKING 1
@@ -119,6 +128,14 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_connect0
return -1;
}
+ if (AF_INET == sa.him4.sin_family) {
+ char buf[INET_ADDRSTRLEN];
+ Trc_PlainSocketImpl_socketConnect4("DualStack ", fd, inet_ntop(AF_INET, &sa.him4.sin_addr, buf, sizeof(buf)), port, sa_len);
+ } else if (AF_INET6 == sa.him6.sin6_family) {
+ char buf[INET6_ADDRSTRLEN];
+ Trc_PlainSocketImpl_socketConnect6("DualStack ", fd, inet_ntop(AF_INET6, &sa.him6.sin6_addr, buf, sizeof(buf)), port, ntohl(sa.him6.sin6_scope_id), sa_len);
+ }
+
rv = connect(fd, (struct sockaddr *)&sa, sa_len);
if (rv == SOCKET_ERROR) {
int err = WSAGetLastError();
@@ -349,6 +366,7 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_available0
*/
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_close0
(JNIEnv *env, jclass clazz, jint fd) {
+ Trc_PlainSocketImpl_socketClose("DualStack ", fd);
NET_SocketClose(fd);
}
diff --git a/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c b/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c
index bf7c047f88e..1c7cb13dcd9 100644
--- a/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c
+++ b/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include
#include
#include
@@ -41,6 +47,8 @@
#include "net_util.h"
#include "jni_util.h"
+#include "ut_jcl_net.h"
+
/************************************************************************
* TwoStacksPlainSocketImpl
*/
@@ -258,6 +266,14 @@ Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
}
(*env)->SetObjectField(env, this, psi_fd1ID, NULL);
+ if (AF_INET == family) {
+ char buf[INET_ADDRSTRLEN];
+ Trc_PlainSocketImpl_socketConnect4("TwoStacks ", fd, inet_ntop(AF_INET, &him.him4.sin_addr, buf, sizeof(buf)), port, len);
+ } else if (AF_INET6 == family) {
+ char buf[INET6_ADDRSTRLEN];
+ Trc_PlainSocketImpl_socketConnect6("TwoStacks ", fd, inet_ntop(AF_INET6, &him.him6.sin6_addr, buf, sizeof(buf)), port, ntohl(him.him6.sin6_scope_id), len);
+ }
+
if (timeout <= 0) {
connect_res = connect(fd, (struct sockaddr *) &him, SOCKETADDRESS_LEN(&him));
if (connect_res == SOCKET_ERROR) {
@@ -826,10 +842,12 @@ Java_java_net_TwoStacksPlainSocketImpl_socketClose0(JNIEnv *env, jobject this,
fd1 = (*env)->GetIntField(env, fd1Obj, IO_fd_fdID);
}
if (fd != -1) {
+ Trc_PlainSocketImpl_socketClose("", fd);
(*env)->SetIntField(env, fdObj, IO_fd_fdID, -1);
NET_SocketClose(fd);
}
if (fd1 != -1) {
+ Trc_PlainSocketImpl_socketClose("fd1 ", fd1);
(*env)->SetIntField(env, fd1Obj, IO_fd_fdID, -1);
NET_SocketClose(fd1);
}
diff --git a/jdk/src/windows/native/sun/nio/ch/FileDispatcherImpl.c b/jdk/src/windows/native/sun/nio/ch/FileDispatcherImpl.c
index 753725f0dad..a89634299e4 100644
--- a/jdk/src/windows/native/sun/nio/ch/FileDispatcherImpl.c
+++ b/jdk/src/windows/native/sun/nio/ch/FileDispatcherImpl.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include
#include "jni.h"
#include "jni_util.h"
@@ -34,6 +40,8 @@
#include "nio_util.h"
#include "jlong.h"
+#include "ut_jcl_nio.h"
+
/**************************************************************
* FileDispatcherImpl.c
@@ -469,6 +477,7 @@ Java_sun_nio_ch_FileDispatcherImpl_release0(JNIEnv *env, jobject this,
static void closeFile(JNIEnv *env, jlong fd) {
HANDLE h = (HANDLE)fd;
if (h != INVALID_HANDLE_VALUE) {
+ Trc_nio_ch_FileDispatcherImpl_close(fd);
int result = CloseHandle(h);
if (result < 0)
JNU_ThrowIOExceptionWithLastError(env, "Close failed");
diff --git a/jdk/src/windows/native/sun/nio/ch/Net.c b/jdk/src/windows/native/sun/nio/ch/Net.c
index 6ff0e54413e..a9103f6b487 100644
--- a/jdk/src/windows/native/sun/nio/ch/Net.c
+++ b/jdk/src/windows/native/sun/nio/ch/Net.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include
#include
#include "jni.h"
@@ -37,6 +43,8 @@
#include "sun_nio_ch_Net.h"
#include "sun_nio_ch_PollArrayWrapper.h"
+#include "ut_jcl_nio.h"
+
/**
* Definitions to allow for building with older SDK include files.
*/
@@ -208,6 +216,14 @@ Java_sun_nio_ch_Net_connect0(JNIEnv *env, jclass clazz, jboolean preferIPv6, job
return IOS_THROWN;
}
+ if (AF_INET == sa.him4.sin_family) {
+ char buf[INET_ADDRSTRLEN];
+ Trc_nio_ch_Net_connect4((jlong)s, inet_ntop(AF_INET, &sa.him4.sin_addr, buf, sizeof(buf)), port, sa_len);
+ } else if (AF_INET6 == sa.him6.sin6_family) {
+ char buf[INET6_ADDRSTRLEN];
+ Trc_nio_ch_Net_connect6((jlong)s, inet_ntop(AF_INET6, &sa.him6.sin6_addr, buf, sizeof(buf)), port, ntohl(sa.him6.sin6_scope_id), sa_len);
+ }
+
rv = connect(s, (struct sockaddr *)&sa, sa_len);
if (rv != 0) {
int err = WSAGetLastError();
diff --git a/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c b/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c
index e8a7186d36f..c888f9a0c62 100644
--- a/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c
+++ b/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c
@@ -23,6 +23,12 @@
* questions.
*/
+/*
+ * ===========================================================================
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
+ * ===========================================================================
+ */
+
#include
#include
#include
@@ -34,6 +40,8 @@
#include "nio.h"
#include "nio_util.h"
+#include "ut_jcl_nio.h"
+
/**************************************************************
* SocketDispatcher.c
@@ -282,6 +290,7 @@ Java_sun_nio_ch_SocketDispatcher_close0(JNIEnv *env, jclass clazz,
jobject fdo)
{
jint fd = fdval(env, fdo);
+ Trc_nio_ch_SocketDispatcher_close(fd);
if (closesocket(fd) == SOCKET_ERROR) {
JNU_ThrowIOExceptionWithLastError(env, "Socket close failed");
}