diff --git a/bin/include/jvmdefaults.bat b/bin/include/jvmdefaults.bat
index e9002a4141266..13ebc69dfc700 100644
--- a/bin/include/jvmdefaults.bat
+++ b/bin/include/jvmdefaults.bat
@@ -43,7 +43,7 @@ if %java_version% GEQ 9 if %java_version% LSS 11 (
%current_value%
)
-if %java_version% GEQ 11 if %java_version% LSS 15 (
+if %java_version% GEQ 11 if %java_version% LSS 14 (
set value= ^
--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^
@@ -55,8 +55,22 @@ if %java_version% GEQ 11 if %java_version% LSS 15 (
%current_value%
)
+if %java_version% GEQ 14 if %java_version% LSS 15 (
+ set value= ^
+ --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^
+ --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^
+ --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^
+ --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^
+ --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^
+ --add-opens=java.base/jdk.internal.access=ALL-UNNAMED ^
+ --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED ^
+ --illegal-access=permit ^
+ %current_value%
+)
+
if %java_version% GEQ 15 (
set value= ^
+ --add-opens=java.base/jdk.internal.access=ALL-UNNAMED ^
--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED ^
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED ^
--add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^
diff --git a/bin/include/jvmdefaults.sh b/bin/include/jvmdefaults.sh
index f0d2519c5c0a3..962b10e469503 100644
--- a/bin/include/jvmdefaults.sh
+++ b/bin/include/jvmdefaults.sh
@@ -41,7 +41,7 @@ getJavaSpecificOpts() {
--add-modules=java.xml.bind \
${current_value}"
- elif [ "${version}" -ge 11 ] && [ "${version}" -lt 15 ]; then
+ elif [ "${version}" -ge 11 ] && [ "${version}" -lt 14 ]; then
value="\
--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
@@ -52,8 +52,21 @@ getJavaSpecificOpts() {
--illegal-access=permit \
${current_value}"
+ elif [ "${version}" -ge 14 ] && [ "${version}" -lt 15 ]; then
+ value="\
+ --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \
+ --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
+ --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \
+ --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \
+ --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \
+ --add-opens=java.base/jdk.internal.access=ALL-UNNAMED \
+ --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED \
+ --illegal-access=permit \
+ ${current_value}"
+
elif [ "${version}" -ge 15 ] ; then
value="\
+ --add-opens=java.base/jdk.internal.access=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED \
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED \
--add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \
diff --git a/deliveries/docker/apache-ignite/run.sh b/deliveries/docker/apache-ignite/run.sh
index 7e88a36b21f67..bacb588325c9a 100755
--- a/deliveries/docker/apache-ignite/run.sh
+++ b/deliveries/docker/apache-ignite/run.sh
@@ -98,6 +98,7 @@ elif [ "${version}" -ge 11 ] ; then
--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \
--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED \
+ --add-opens=java.base/jdk.internal.access=ALL-UNNAMED \
--illegal-access=permit \
${JVM_OPTS}"
fi
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/FeatureChecker.java b/modules/core/src/main/java/org/apache/ignite/internal/util/FeatureChecker.java
index f017be33a8b14..b53e52c183e36 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/FeatureChecker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/FeatureChecker.java
@@ -28,10 +28,12 @@ public class FeatureChecker {
"--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED\n" +
"--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED\n" +
"--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED\n" +
+ "--add-opens=java.base/jdk.internal.access=ALL-UNNAMED\n" +
"--illegal-access=permit";
/** Required Options to Run on Java 15 and higher. */
public static final String JAVA_15_OPTIONS =
+ "--add-opens=java.base/jdk.internal.access=ALL-UNNAMED\n" +
"--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED\n" +
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED\n" +
"--add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED\n" +
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
index ef215493cac5d..ce9476f4916a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
@@ -117,6 +117,12 @@ public abstract class GridUnsafe {
/** Whether to use newDirectByteBuffer(long, long) constructor */
private static final boolean IS_DIRECT_BUF_LONG_CAP = majorJavaVersion(jdkVersion()) >= 21;
+ /** Whether {@link jdk.internal.access.JavaNioAccess} has new byte buffer api. */
+ private static final boolean HAS_JAVA_NIO_ACCESS_NEW_API = majorJavaVersion(jdkVersion()) >= 14;
+
+ /** Whether {@link jdk.internal.access.JavaNioAccess#newDirectByteBuffer} has param of type {@link java.lang.foreign.MemorySegment}. */
+ private static final boolean HAS_JAVA_NIO_ACCESS_MEMORY_SEGMENT_PARAM = majorJavaVersion(jdkVersion()) >= 19;
+
/** Cleaner code for direct {@code java.nio.ByteBuffer}. */
private static final DirectBufferCleaner DIRECT_BUF_CLEANER =
majorJavaVersion(jdkVersion()) < 9
@@ -174,6 +180,9 @@ public abstract class GridUnsafe {
directBufCtor = createAndTestNewDirectBufferCtor();
}
catch (Exception e) {
+ if (!HAS_JAVA_NIO_ACCESS_NEW_API)
+ throw e;
+
try {
nioAccessObj = javaNioAccessObject();
directBufMtd = newDirectBufferMethod(nioAccessObj);
@@ -257,7 +266,11 @@ else if (NEW_DIRECT_BUF_CONSTRUCTOR != null)
@NotNull Method newDirectBufMtd,
@NotNull Object javaNioAccessObj) {
try {
- ByteBuffer buf = (ByteBuffer)newDirectBufMtd.invoke(javaNioAccessObj, ptr, len, null);
+ ByteBuffer buf;
+ if (HAS_JAVA_NIO_ACCESS_NEW_API)
+ buf = (ByteBuffer)newDirectBufMtd.invoke(javaNioAccessObj, ptr, len, null, null);
+ else
+ buf = (ByteBuffer)newDirectBufMtd.invoke(javaNioAccessObj, ptr, len, null);
assert buf.isDirect();
@@ -1617,17 +1630,17 @@ private static long bufferAddressOffset() {
* @throws RuntimeException If getting access to the private API is failed.
*/
private static Object javaNioAccessObject() {
- String pkgName = miscPackage();
+ String pkgName = getSharedSecretsPackage();
try {
- Class> cls = Class.forName(pkgName + ".misc.SharedSecrets");
+ Class> cls = Class.forName(pkgName + ".SharedSecrets");
Method mth = cls.getMethod("getJavaNioAccess");
return mth.invoke(null);
}
catch (ReflectiveOperationException e) {
- throw new RuntimeException(pkgName + ".misc.JavaNioAccess class is unavailable."
+ throw new RuntimeException(pkgName + ".JavaNioAccess class is unavailable."
+ FeatureChecker.JAVA_VER_SPECIFIC_WARN, e);
}
}
@@ -1644,24 +1657,40 @@ private static Method newDirectBufferMethod(Object nioAccessObj) {
try {
Class> cls = nioAccessObj.getClass();
- Method mtd = IS_DIRECT_BUF_LONG_CAP ? cls.getMethod("newDirectByteBuffer", long.class, long.class, Object.class) :
- cls.getMethod("newDirectByteBuffer", long.class, int.class, Object.class);
+ Method mtd;
+ if (HAS_JAVA_NIO_ACCESS_NEW_API) {
+ Class> forthParamCls;
+ if (HAS_JAVA_NIO_ACCESS_MEMORY_SEGMENT_PARAM)
+ forthParamCls = Class.forName("java.lang.foreign.MemorySegment");
+ else
+ forthParamCls = Class.forName("jdk.internal.access.foreign.MemorySegmentProxy");
+
+ mtd = cls.getMethod("newDirectByteBuffer", long.class, int.class, Object.class, forthParamCls);
+ }
+ else
+ mtd = cls.getMethod("newDirectByteBuffer", long.class, int.class, Object.class);
mtd.setAccessible(true);
return mtd;
}
catch (ReflectiveOperationException e) {
- throw new RuntimeException(miscPackage() + ".JavaNioAccess#newDirectByteBuffer() method is unavailable."
+ throw new RuntimeException(getSharedSecretsPackage() + ".JavaNioAccess#newDirectByteBuffer() method is unavailable."
+ FeatureChecker.JAVA_VER_SPECIFIC_WARN, e);
}
}
/** */
- @NotNull private static String miscPackage() {
+ @NotNull private static String getSharedSecretsPackage() {
int javaVer = majorJavaVersion(jdkVersion());
- return javaVer < 9 ? "sun" : "jdk.internal";
+ if (javaVer < 9)
+ return "sun.misc";
+
+ if (javaVer < 12)
+ return "jdk.internal.misc";
+
+ return "jdk.internal.access";
}
/**
diff --git a/modules/platforms/cpp/core/src/ignition.cpp b/modules/platforms/cpp/core/src/ignition.cpp
index ea4190664af34..ccc5c7dbf1377 100644
--- a/modules/platforms/cpp/core/src/ignition.cpp
+++ b/modules/platforms/cpp/core/src/ignition.cpp
@@ -153,6 +153,7 @@ namespace ignite
// Those are only needed for Java 15+, but Java 15 can not be detected easily using JNI,
// so just putting it here in case we are running on 15+. It is OK to have them on Java 9-14 too.
// See https://docs.oracle.com/en/java/javase/17/docs/specs/jni/functions.html#getversion
+ opts.push_back(CopyChars("--add-opens=java.base/jdk.internal.access=ALL-UNNAMED"));
opts.push_back(CopyChars("--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED"));
opts.push_back(CopyChars("--add-opens=java.base/sun.nio.ch=ALL-UNNAMED"));
opts.push_back(CopyChars("--add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED"));
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Jvm.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Jvm.cs
index 47b685a2223ba..30f3fc669e72e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Jvm.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Jvm.cs
@@ -52,6 +52,7 @@ internal sealed unsafe partial class Jvm
"--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED",
"--illegal-access=permit",
+ "--add-opens=java.base/jdk.internal.access=ALL-UNNAMED",
"--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED",
diff --git a/parent/pom.xml b/parent/pom.xml
index d67b144c19376..24da59734c095 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -918,7 +918,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --illegal-access=permit
+ --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens=java.base/jdk.internal.access=ALL-UNNAMED --illegal-access=permit
@@ -1012,6 +1012,7 @@
maven-surefire-plugin
+ --add-opens=java.base/jdk.internal.access=ALL-UNNAMED
--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED