diff --git a/CHANGES.txt b/CHANGES.txt
index 2c6624abbc..0d67ab6cf7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
5.0-alpha2
+ * Update command line flags --add-exports and --add-opens for JDK17 (CASSANDRA-18439)
* Update commons-lang3 to 3.13.0 (CASSANDRA-18789)
* Forbid SAI indexes with analysis options on primary key columns (CASSANDRA-18782)
Merged from 4.1:
diff --git a/build.xml b/build.xml
index ea6cfac5ad..9f85e875d0 100644
--- a/build.xml
+++ b/build.xml
@@ -238,8 +238,6 @@
-XX:G1HeapRegionSize=16m
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
- --add-exports java.base/jdk.internal.ref=ALL-UNNAMED
- --add-exports java.base/sun.nio.ch=ALL-UNNAMED
--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED
--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED
--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED
@@ -248,9 +246,9 @@
--add-exports java.base/java.lang.ref=ALL-UNNAMED
--add-exports jdk.unsupported/sun.misc=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
+ --add-exports jdk.attach/sun.tools.attach=ALL-UNNAMED
--add-opens java.base/java.lang.module=ALL-UNNAMED
- --add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED
@@ -258,17 +256,12 @@
--add-opens java.base/jdk.internal.module=ALL-UNNAMED
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
- --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
-
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
- --add-opens java.base/java.util.concurrent=ALL-UNNAMED
- --add-opens java.base/java.util=ALL-UNNAMED
- --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED
- --add-opens java.base/java.lang=ALL-UNNAMED
- --add-opens java.base/java.math=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
- --add-opens java.base/java.net=ALL-UNNAMED
+ --add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED
+ --add-opens java.base/java.lang=ALL-UNNAMED
+ --add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED
diff --git a/conf/jvm17-clients.options b/conf/jvm17-clients.options
index 023ca52e81..4c12fa378c 100644
--- a/conf/jvm17-clients.options
+++ b/conf/jvm17-clients.options
@@ -28,12 +28,11 @@
-Djdk.attach.allowAttachSelf=true
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
---add-exports java.base/jdk.internal.ref=ALL-UNNAMED
---add-exports java.base/sun.nio.ch=ALL-UNNAMED
--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED
--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED
--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED
--add-exports java.sql/java.sql=ALL-UNNAMED
+--add-exports java.base/java.lang.ref=ALL-UNNAMED
--add-exports jdk.unsupported/sun.misc=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.attach/sun.tools.attach=ALL-UNNAMED
@@ -48,21 +47,11 @@
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
-# to be addressed in CASSANDRA-17850
---add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
-# to be addressed during jamm maintenance
---add-opens java.base/java.util.concurrent=ALL-UNNAMED
---add-opens java.base/java.util=ALL-UNNAMED
---add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED
-# jamm and the in-jvm tests...
--add-opens java.base/java.lang=ALL-UNNAMED
-# jamm
---add-opens java.base/java.math=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED
---add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
-#jamm post CASSANDRA-17199
---add-opens java.base/java.net=ALL-UNNAMED
+--add-opens java.base/java.util=ALL-UNNAMED
+
# The newline in the end of file is intentional
diff --git a/conf/jvm17-server.options b/conf/jvm17-server.options
index 53cc13c86b..39c1810d16 100644
--- a/conf/jvm17-server.options
+++ b/conf/jvm17-server.options
@@ -63,19 +63,14 @@
-Djdk.attach.allowAttachSelf=true
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
---add-exports java.base/jdk.internal.ref=ALL-UNNAMED
-# https://chronicle.software/chronicle-support-java-17/
---add-exports java.base/sun.nio.ch=ALL-UNNAMED
--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED
--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED
--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED
--add-exports java.sql/java.sql=ALL-UNNAMED
-
-#chronicle, AuditLog https://chronicle.software/chronicle-support-java-17/
--add-exports java.base/java.lang.ref=ALL-UNNAMED
---add-exports java.base/jdk.internal.util=ALL-UNNAMED
--add-exports jdk.unsupported/sun.misc=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
+--add-exports jdk.attach/sun.tools.attach=ALL-UNNAMED
--add-opens java.base/java.lang.module=ALL-UNNAMED
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
@@ -85,25 +80,12 @@
--add-opens java.base/jdk.internal.module=ALL-UNNAMED
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
-
-#to be addressed in CASSANDRA-17850
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
-# https://chronicle.software/chronicle-support-java-17/
--add-opens java.base/java.io=ALL-UNNAMED
-#to be addressed during jamm maintenance
---add-opens java.base/java.util.concurrent=ALL-UNNAMED
---add-opens java.base/java.util=ALL-UNNAMED
---add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED
-# https://chronicle.software/chronicle-support-java-17/ explains also --add-opens java.base/java.util=ALL-UNNAMED, further to jamm
-# many cqlsh tests fail if we do not open the below one - jamm and at org.apache.cassandra.net.Verb.getModifiersField(Verb.java:388)
-# in-jvm tests
---add-opens java.base/java.lang=ALL-UNNAMED
-#jamm
---add-opens java.base/java.math=ALL-UNNAMED
-#in-jvm tests? plus # https://chronicle.software/chronicle-support-java-17/
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
-#jamm post CASSANDRA-17199
---add-opens java.base/java.net=ALL-UNNAMED
+--add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED
+--add-opens java.base/java.lang=ALL-UNNAMED
+--add-opens java.base/java.util=ALL-UNNAMED
### GC logging options -- uncomment to enable