|
19 | 19 | package org.netbeans.modules.payara.tooling.data; |
20 | 20 |
|
21 | 21 | import java.util.Optional; |
| 22 | +import org.netbeans.modules.payara.tooling.server.parser.JvmConfigReader; |
22 | 23 |
|
23 | 24 | public final class JDKVersion { |
24 | 25 |
|
@@ -283,24 +284,51 @@ public static JDKVersion getDefaultPlatformVersion() { |
283 | 284 | return IDE_JDK_VERSION; |
284 | 285 | } |
285 | 286 |
|
286 | | - public static boolean isCorrectJDK(JDKVersion jdkVersion, Optional<String> vendorOrVM, Optional<JDKVersion> minVersion, Optional<JDKVersion> maxVersion) { |
| 287 | + public boolean isOptionSupported( |
| 288 | + JvmConfigReader.JvmOption jvmOption, |
| 289 | + String javaHome) { |
| 290 | + |
287 | 291 | boolean correctJDK = true; |
288 | 292 |
|
289 | | - if (vendorOrVM.isPresent()) { |
290 | | - correctJDK = jdkVersion.getVendor().map(vendor -> vendor.contains(vendorOrVM.get())).orElse(false) |
291 | | - || jdkVersion.getVM().map(vm -> vm.contains(vendorOrVM.get())).orElse(false); |
| 293 | + if (jvmOption.vendorOrVM.isPresent()) { |
| 294 | + correctJDK |
| 295 | + = this.getVendor() |
| 296 | + .map(v -> v.contains(jvmOption.vendorOrVM.get())) |
| 297 | + .orElse(false) |
| 298 | + || this.getVM() |
| 299 | + .map(vm -> vm.contains(jvmOption.vendorOrVM.get())) |
| 300 | + .orElse(false); |
292 | 301 | } |
293 | | - if (correctJDK && minVersion.isPresent()) { |
294 | | - correctJDK = jdkVersion.ge(minVersion.get()); |
| 302 | + |
| 303 | + if (correctJDK && jvmOption.minVersion.isPresent()) { |
| 304 | + correctJDK = this.ge(jvmOption.minVersion.get()); |
295 | 305 | } |
296 | | - if (correctJDK && maxVersion.isPresent()) { |
297 | | - correctJDK = jdkVersion.le(maxVersion.get()); |
| 306 | + |
| 307 | + if (correctJDK && jvmOption.maxVersion.isPresent()) { |
| 308 | + correctJDK = this.le(jvmOption.maxVersion.get()); |
| 309 | + } |
| 310 | + |
| 311 | + if (correctJDK |
| 312 | + && jvmOption.option != null |
| 313 | + && jvmOption.option.matches("^-XX:[+-]?CRaC.*")) { |
| 314 | + |
| 315 | + correctJDK = this.isCRaCSupported(javaHome); |
298 | 316 | } |
299 | 317 | return correctJDK; |
300 | 318 | } |
301 | 319 |
|
302 | | - public static boolean isCorrectJDK(Optional<JDKVersion> minVersion, Optional<JDKVersion> maxVersion) { |
303 | | - return isCorrectJDK(IDE_JDK_VERSION, Optional.empty(), minVersion, maxVersion); |
| 320 | + /** |
| 321 | + * Checks whether the given JDK installation supports CRaC by verifying the |
| 322 | + * presence of the lib/criu directory. |
| 323 | + * |
| 324 | + * @param javaHome Java home directory to check |
| 325 | + * @return true if CRaC-enabled JDK |
| 326 | + */ |
| 327 | + private boolean isCRaCSupported(String javaHome) { |
| 328 | + return Optional.ofNullable(javaHome) |
| 329 | + .map(home -> new java.io.File(home, "lib/criu")) |
| 330 | + .map(java.io.File::exists) |
| 331 | + .orElse(false); |
304 | 332 | } |
305 | 333 |
|
306 | 334 | static { |
|
0 commit comments