matthiasblaesing commented on code in PR #9237:
URL: https://github.com/apache/netbeans/pull/9237#discussion_r2995994239
##########
enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/data/JDKVersion.java:
##########
@@ -283,24 +283,55 @@ public static JDKVersion getDefaultPlatformVersion() {
return IDE_JDK_VERSION;
}
- public static boolean isCorrectJDK(JDKVersion jdkVersion, Optional<String>
vendorOrVM, Optional<JDKVersion> minVersion, Optional<JDKVersion> maxVersion) {
+ public static boolean isCorrectJDK(JDKVersion jdkVersion,
Review Comment:
I think this method is badly named. I think a name like `isOptionSupported`
would better descript what is done here.
##########
enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/server/ServerTasks.java:
##########
@@ -157,11 +157,22 @@ public static ResultProcess startServer(PayaraServer
server,
}
}
- JDKVersion javaVersion = args.getJavaVersion() == null ?
JDKVersion.getDefaultPlatformVersion() : args.getJavaVersion() ;
+ JDKVersion javaVersion = args.getJavaVersion() == null ?
JDKVersion.getDefaultPlatformVersion() : args.getJavaVersion();
+ String selectedJavaHome
+ = args.getJavaHome() != null
+ ? args.getJavaHome()
+ : System.getProperty("java.home");
List<String> optList
= jvmConfigReader.getJvmOptions()
.stream()
- .filter(fullOption ->
JDKVersion.isCorrectJDK(javaVersion, fullOption.vendorOrVM,
fullOption.minVersion, fullOption.maxVersion))
+ .filter(fullOption
+ -> JDKVersion.isCorrectJDK(
+ javaVersion,
+ fullOption.vendorOrVM,
+ fullOption.minVersion,
+ fullOption.maxVersion,
+ fullOption.option,
Review Comment:
Why not just pass the full `JvmOption` here?
##########
enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/data/JDKVersion.java:
##########
@@ -283,24 +283,55 @@ public static JDKVersion getDefaultPlatformVersion() {
return IDE_JDK_VERSION;
}
- public static boolean isCorrectJDK(JDKVersion jdkVersion, Optional<String>
vendorOrVM, Optional<JDKVersion> minVersion, Optional<JDKVersion> maxVersion) {
+ public static boolean isCorrectJDK(JDKVersion jdkVersion,
+ Optional<String> vendorOrVM,
+ Optional<JDKVersion> minVersion,
+ Optional<JDKVersion> maxVersion,
+ String jvmOption,
+ String javaHome) {
+
boolean correctJDK = true;
if (vendorOrVM.isPresent()) {
- correctJDK = jdkVersion.getVendor().map(vendor ->
vendor.contains(vendorOrVM.get())).orElse(false)
- || jdkVersion.getVM().map(vm ->
vm.contains(vendorOrVM.get())).orElse(false);
+ correctJDK
+ = jdkVersion.getVendor()
+ .map(v -> v.contains(vendorOrVM.get()))
+ .orElse(false)
+ || jdkVersion.getVM()
+ .map(vm -> vm.contains(vendorOrVM.get()))
+ .orElse(false);
}
+
if (correctJDK && minVersion.isPresent()) {
correctJDK = jdkVersion.ge(minVersion.get());
}
+
if (correctJDK && maxVersion.isPresent()) {
correctJDK = jdkVersion.le(maxVersion.get());
}
+
+ if (correctJDK
+ && jvmOption != null
+ && jvmOption.matches("^-XX:[+-]?CRaC.*")) {
+
+ correctJDK = isCRaCJDK(javaHome);
+ }
+
return correctJDK;
}
- public static boolean isCorrectJDK(Optional<JDKVersion> minVersion,
Optional<JDKVersion> maxVersion) {
- return isCorrectJDK(IDE_JDK_VERSION, Optional.empty(), minVersion,
maxVersion);
+ /**
+ * Checks whether the given JDK installation supports CRaC by verifying the
+ * presence of the lib/criu directory.
+ *
+ * @param javaHome Java home directory to check
+ * @return true if CRaC-enabled JDK
+ */
+ public static boolean isCRaCJDK(String javaHome) {
+ return Optional.ofNullable(javaHome)
+ .map(home -> new java.io.File(home, "lib/criu"))
+ .map(java.io.File::exists)
+ .orElse(false);
}
Review Comment:
From my POV this is a property of the JDK so I would see this as part of
`JDKVersion`?
--
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]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists