Skip to content

Commit ab93366

Browse files
author
duke
committed
Automatic merge of jdk:master into master
2 parents 0963e77 + 952abea commit ab93366

File tree

4 files changed

+115
-5
lines changed

4 files changed

+115
-5
lines changed

src/jdk.jpackage/windows/native/applauncher/WinLauncher.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ void launchApp() {
137137

138138
const tstring launcherPath = SysInfo::getProcessModulePath();
139139
const tstring appImageRoot = FileUtils::dirname(launcherPath);
140+
const tstring runtimeBinPath = FileUtils::mkpath()
141+
<< appImageRoot << _T("runtime") << _T("bin");
140142

141143
std::unique_ptr<Jvm> jvm(AppLauncher()
142144
.setImageRoot(appImageRoot)
@@ -146,6 +148,10 @@ void launchApp() {
146148
<< _T("runtime"))
147149
.createJvmLauncher());
148150

151+
// zip.dll may be loaded by java without full path
152+
// make sure it will look in runtime/bin
153+
SetDllDirectory(runtimeBinPath.c_str());
154+
149155
const DllWrapper jliDll(jvm->getPath());
150156
std::unique_ptr<DllWrapper> splashDll;
151157
if (jvm->isWithSplash()) {

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public static Executor of(String... cmdline) {
5252

5353
public Executor() {
5454
saveOutputType = new HashSet<>(Set.of(SaveOutputType.NONE));
55+
removePath = false;
5556
}
5657

5758
public Executor setExecutable(String v) {
@@ -83,6 +84,11 @@ public Executor setExecutable(JavaTool v) {
8384
return setExecutable(v.getPath());
8485
}
8586

87+
public Executor setRemovePath(boolean value) {
88+
removePath = value;
89+
return this;
90+
}
91+
8692
/**
8793
* Configures this instance to save full output that command will produce.
8894
* This function is mutual exclusive with
@@ -289,6 +295,11 @@ private Result runExecutable() throws IOException, InterruptedException {
289295
builder.directory(directory.toFile());
290296
sb.append(String.format("; in directory [%s]", directory));
291297
}
298+
if (removePath) {
299+
// run this with cleared Path in Environment
300+
TKit.trace("Clearing PATH in environment");
301+
builder.environment().remove("PATH");
302+
}
292303

293304
trace("Execute " + sb.toString() + "...");
294305
Process process = builder.start();
@@ -414,6 +425,7 @@ private static void trace(String msg) {
414425
private Path executable;
415426
private Set<SaveOutputType> saveOutputType;
416427
private Path directory;
428+
private boolean removePath;
417429

418430
private static enum SaveOutputType {
419431
NONE, FULL, FIRST_LINE, DUMP

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,15 @@ public static void executeLauncherAndVerifyOutput(JPackageCommand cmd,
273273
String... args) {
274274
AppOutputVerifier av = getVerifier(cmd, args);
275275
if (av != null) {
276-
av.executeAndVerifyOutput(args);
276+
// when running app launchers, clear users environment
277+
av.executeAndVerifyOutput(true, args);
277278
}
278279
}
279280

280281
public static Executor.Result executeLauncher(JPackageCommand cmd,
281282
String... args) {
282283
AppOutputVerifier av = getVerifier(cmd, args);
283-
return av.executeOnly(args);
284+
return av.executeOnly(true, args);
284285
}
285286

286287
private static AppOutputVerifier getVerifier(JPackageCommand cmd,
@@ -351,7 +352,11 @@ public AppOutputVerifier addJavaOptions(Collection<String> v) {
351352
}
352353

353354
public void executeAndVerifyOutput(String... args) {
354-
getExecutor(args).dumpOutput().execute();
355+
executeAndVerifyOutput(false, args);
356+
}
357+
358+
public void executeAndVerifyOutput(boolean removePath, String... args) {
359+
getExecutor(args).dumpOutput().setRemovePath(removePath).execute();
355360

356361
final List<String> launcherArgs = List.of(args);
357362
final List<String> appArgs;
@@ -365,8 +370,11 @@ public void executeAndVerifyOutput(String... args) {
365370
verifyOutputFile(outputFile, appArgs, params);
366371
}
367372

368-
public Executor.Result executeOnly(String...args) {
369-
return getExecutor(args).saveOutput().executeWithoutExitCodeCheck();
373+
public Executor.Result executeOnly(boolean removePath, String...args) {
374+
return getExecutor(args)
375+
.saveOutput()
376+
.setRemovePath(removePath)
377+
.executeWithoutExitCodeCheck();
370378
}
371379

372380
private Executor getExecutor(String...args) {
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import java.io.IOException;
25+
import java.nio.file.Files;
26+
import java.nio.file.Path;
27+
import java.util.HashSet;
28+
import java.util.Optional;
29+
import java.util.Set;
30+
import java.util.stream.Collectors;
31+
import jdk.jpackage.test.TKit;
32+
import jdk.jpackage.test.PackageTest;
33+
import jdk.jpackage.test.PackageType;
34+
import jdk.jpackage.test.Functional;
35+
import jdk.jpackage.test.Annotations.Test;
36+
import jdk.jpackage.test.Annotations.Parameter;
37+
import jdk.jpackage.test.PackageTest;
38+
import jdk.jpackage.test.JPackageCommand;
39+
import jdk.jpackage.test.JavaTool;
40+
import jdk.jpackage.test.Executor;
41+
42+
/*
43+
* @test
44+
* @summary jpackage with --runtime-image
45+
* @library ../helpers
46+
* @key jpackagePlatformPackage
47+
* @build jdk.jpackage.test.*
48+
* @modules jdk.incubator.jpackage/jdk.incubator.jpackage.internal
49+
* @compile RuntimeImageTest.java
50+
* @run main/othervm/timeout=1400 -Xmx512m jdk.jpackage.test.Main
51+
* --jpt-run=RuntimeImageTest
52+
*/
53+
54+
public class RuntimeImageTest {
55+
56+
@Test
57+
@Parameter("0")
58+
@Parameter("1")
59+
@Parameter("2")
60+
public static void test(String compression) throws Exception {
61+
final Path workDir = TKit.createTempDirectory("runtime").resolve("data");
62+
final Path jlinkOutputDir = workDir.resolve("temp.runtime");
63+
Files.createDirectories(jlinkOutputDir.getParent());
64+
65+
new Executor()
66+
.setToolProvider(JavaTool.JLINK)
67+
.dumpOutput()
68+
.addArguments(
69+
"--output", jlinkOutputDir.toString(),
70+
"--compress=" + compression,
71+
"--add-modules", "ALL-MODULE-PATH",
72+
"--strip-debug",
73+
"--no-header-files",
74+
"--no-man-pages",
75+
"--strip-native-commands")
76+
.execute();
77+
78+
JPackageCommand cmd = JPackageCommand.helloAppImage()
79+
.setArgumentValue("--runtime-image", jlinkOutputDir.toString());
80+
81+
cmd.executeAndAssertHelloAppImageCreated();
82+
}
83+
84+
}

0 commit comments

Comments
 (0)