Skip to content

Commit b6218f8

Browse files
ankhunticoffeys
authored andcommitted
8347298: Bug in JPackageCommand.ignoreFakeRuntime()
Backport-of: 01c8ba2cde881c3d483cb776ca17a5aa13123b23
1 parent 09d777a commit b6218f8

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -593,7 +593,7 @@ public Path appLauncherCfgPath(String launcherName) {
593593
}
594594

595595
public boolean isFakeRuntime(String msg) {
596-
if (isFakeRuntime()) {
596+
if (isFakeRuntime(appRuntimeDirectory())) {
597597
// Fake runtime
598598
Path runtimeDir = appRuntimeDirectory();
599599
TKit.trace(String.format(
@@ -604,7 +604,7 @@ public boolean isFakeRuntime(String msg) {
604604
return false;
605605
}
606606

607-
private boolean isFakeRuntime() {
607+
private static boolean isFakeRuntime(Path runtimeDir) {
608608
final Collection<Path> criticalRuntimeFiles;
609609
if (TKit.isWindows()) {
610610
criticalRuntimeFiles = WindowsHelper.CRITICAL_RUNTIME_FILES;
@@ -616,7 +616,6 @@ private boolean isFakeRuntime() {
616616
throw TKit.throwUnknownPlatformError();
617617
}
618618

619-
Path runtimeDir = appRuntimeDirectory();
620619
return !criticalRuntimeFiles.stream().map(runtimeDir::resolve).allMatch(
621620
Files::exists);
622621
}
@@ -690,10 +689,8 @@ public JPackageCommand ignoreDefaultRuntime(boolean v) {
690689
}
691690

692691
public JPackageCommand ignoreFakeRuntime() {
693-
if (isFakeRuntime()) {
694-
ignoreDefaultRuntime(true);
695-
}
696-
return this;
692+
return ignoreDefaultRuntime(Optional.ofNullable(DEFAULT_RUNTIME_IMAGE)
693+
.map(JPackageCommand::isFakeRuntime).orElse(false));
697694
}
698695

699696
public JPackageCommand ignoreDefaultVerbose(boolean v) {

0 commit comments

Comments
 (0)