gemini-code-assist[bot] commented on code in PR #39283:
URL: https://github.com/apache/beam/pull/39283#discussion_r3560332501


##########
sdks/java/io/hadoop-format/build.gradle:
##########
@@ -202,3 +202,24 @@ static def createTaskNames(Map<String, String> 
hadoopVersions, String suffix) {
       .map{num -> "runHadoopFormatIO$num$suffix"}
       .collect(Collectors.toList())
 }
+
+def testJavaVer = project.findProperty('testJavaVersion') ?: 
JavaVersion.current().getMajorVersion()
+def isJava17OrHigher = testJavaVer.toInteger() >= 17
+
+tasks.withType(Test).configureEach {
+  if (isJava17OrHigher) {
+    systemProperty 'java.security.manager', 'allow'
+  }
+  // Open and export modules for embedded Cassandra and Elasticsearch under 
Java 17+
+  jvmArgs '--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
+          '--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED',
+          '--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED',
+          '--add-opens=java.base/sun.nio.ch=ALL-UNNAMED',
+          '--add-opens=java.base/java.lang=ALL-UNNAMED',
+          '--add-opens=java.base/java.util=ALL-UNNAMED',
+          '--add-opens=java.base/java.util.concurrent=ALL-UNNAMED',
+          '--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED',
+          '--add-opens=java.base/java.io=ALL-UNNAMED',
+          '--add-opens=java.base/java.net=ALL-UNNAMED',
+          '--add-opens=java.base/java.nio=ALL-UNNAMED'
+}

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   Unconditionally adding `--add-exports` and `--add-opens` JVM arguments will 
cause test execution to fail when running on JDK 8, as these options are not 
recognized by Java 8. These arguments should be nested inside the `if 
(isJava17OrHigher)` block so they are only applied when running on JDK 17 or 
higher.
   
   ```
     if (isJava17OrHigher) {
       systemProperty 'java.security.manager', 'allow'
       // Open and export modules for embedded Cassandra and Elasticsearch 
under Java 17+
       jvmArgs '--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
               '--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED',
               '--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED',
               '--add-opens=java.base/sun.nio.ch=ALL-UNNAMED',
               '--add-opens=java.base/java.lang=ALL-UNNAMED',
               '--add-opens=java.base/java.util=ALL-UNNAMED',
               '--add-opens=java.base/java.util.concurrent=ALL-UNNAMED',
               '--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED',
               '--add-opens=java.base/java.io=ALL-UNNAMED',
               '--add-opens=java.base/java.net=ALL-UNNAMED',
               '--add-opens=java.base/java.nio=ALL-UNNAMED'
     }
   }
   ```



-- 
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]

Reply via email to