dcapwell commented on code in PR #4778:
URL: https://github.com/apache/cassandra/pull/4778#discussion_r3228211878
##########
buildSrc/src/main/groovy/JdkJvmArgs.groovy:
##########
@@ -0,0 +1,233 @@
+/**
+ * Provides JDK-version-specific JVM arguments for compilation, runtime, and
testing.
+ * Mirrors the flag lists from build.xml ({@code _jvm11_arg_items}, {@code
_jvm17_arg_items}, etc.).
+ */
+class JdkJvmArgs {
+
+ /**
+ * {@code --add-exports} flags required by javac (from build.xml {@code
jdk11plus-javac-exports}).
+ */
+ static List<String> javacExports() {
+ return [
+ '--add-exports', 'java.rmi/sun.rmi.registry=ALL-UNNAMED',
+ '--add-exports', 'java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED',
+ '--add-exports', 'java.base/jdk.internal.ref=ALL-UNNAMED',
+ '--add-exports', 'java.base/sun.nio.ch=ALL-UNNAMED',
+ '--add-exports',
'java.management/com.sun.jmx.remote.security=ALL-UNNAMED',
+ ]
+ }
+
+ /**
+ * JDK-specific {@code --add-exports} / {@code --add-opens} for runtime
JVM args.
+ * Mirrors {@code _jvm11_arg_items}, {@code _jvm17_arg_items}, {@code
_jvm21_arg_items}.
+ */
+ static List<String> jvmArgs(int jdkVersion) {
+ switch (jdkVersion) {
+ case 11: return jvm11Args()
+ case 17: return jvm17Args()
+ case 21: return jvm21Args()
+ default:
+ // For unknown/newer JDKs, fall back to JDK 21 args
+ return jvm21Args()
+ }
+ }
+
+ /**
+ * JDK-specific test JVM args.
+ * Mirrors {@code _jvm11_test_arg_items}, {@code _jvm17_test_arg_items},
{@code _jvm21_test_arg_items}.
+ */
+ static List<String> testArgs(int jdkVersion) {
+ switch (jdkVersion) {
+ case 11: return jvm11TestArgs()
+ case 17: return jvm17TestArgs()
+ case 21: return jvm21TestArgs()
+ default:
+ return jvm21TestArgs()
+ }
+ }
+
+ /**
+ * Detect the major version of the running JDK.
+ */
+ static int detectJdkVersion() {
+ String specVersion = System.getProperty('java.specification.version')
+ if (specVersion.contains('.')) {
+ // Pre-JDK 9 format: "1.8"
+ return specVersion.split('\\.')[1] as int
+ }
+ return specVersion as int
+ }
+
+ //
-------------------------------------------------------------------------
+ // JDK 11 runtime args (from build.xml _jvm11_arg_items)
+ //
-------------------------------------------------------------------------
+ private static List<String> jvm11Args() {
+ return [
Review Comment:
we read the properties but hard coded while testing; ill try to extract from
the properly list we read from before.
As for common properties... would need to look into it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]