Skip to content

Commit 85ed78c

Browse files
committedJan 13, 2025
8345185: Update jpackage to not include service bindings by default
Reviewed-by: asemenyuk
1 parent 3b9732e commit 85ed78c

File tree

7 files changed

+49
-24
lines changed

7 files changed

+49
-24
lines changed
 

‎src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import java.util.spi.ToolProvider;
4848
import java.util.stream.Collectors;
4949
import java.util.stream.Stream;
50+
5051
import jdk.internal.module.ModulePath;
5152

5253

@@ -99,8 +100,10 @@ private static Set<String> getDefaultModules(
99100

100101
ModuleFinder finder = createModuleFinder(paths);
101102

103+
// Don't perform service bindings by default as outlined by JEP 343
104+
// and JEP 392
102105
return Configuration.empty()
103-
.resolveAndBind(finder, ModuleFinder.of(), roots)
106+
.resolve(finder, ModuleFinder.of(), roots)
104107
.modules()
105108
.stream()
106109
.map(ResolvedModule::name)

‎test/jdk/tools/jpackage/TEST.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ exclusiveAccess.dirs=share windows
1414
modules=jdk.jpackage/jdk.jpackage.internal:+open \
1515
jdk.jpackage/jdk.jpackage.internal.util \
1616
jdk.jpackage/jdk.jpackage.internal.util.function \
17-
java.base/jdk.internal.util
17+
java.base/jdk.internal.util \
18+
jdk.jlink/jdk.tools.jlink.internal

‎test/jdk/tools/jpackage/share/BasicTest.java

+33-8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import java.nio.file.Path;
2828
import java.util.List;
2929
import java.util.ArrayList;
30+
import java.util.Collection;
31+
import java.util.Collections;
3032
import java.util.Optional;
3133
import java.util.function.Function;
3234
import java.util.function.Predicate;
@@ -41,7 +43,9 @@
4143
import jdk.jpackage.test.JavaTool;
4244
import jdk.jpackage.test.Annotations.Test;
4345
import jdk.jpackage.test.Annotations.Parameter;
46+
import jdk.jpackage.test.Annotations.ParameterSupplier;
4447
import jdk.jpackage.internal.util.function.ThrowingConsumer;
48+
import jdk.tools.jlink.internal.LinkableRuntimeImage;
4549
import static jdk.jpackage.test.RunnablePackageTest.Action.CREATE_AND_UNPACK;
4650

4751
/*
@@ -55,6 +59,32 @@
5559
*/
5660

5761
public final class BasicTest {
62+
63+
public static Collection addModulesParams() {
64+
List<Object[][]> params = new ArrayList<>();
65+
params.add(new Object[][] { new String[] { "--add-modules", "ALL-DEFAULT" } });
66+
params.add(new Object[][] { new String[] { "--add-modules", "java.desktop" } });
67+
params.add(new Object[][] { new String[] { "--add-modules", "java.desktop,jdk.jartool" } });
68+
params.add(new Object[][] { new String[] { "--add-modules", "java.desktop", "--add-modules", "jdk.jartool" } });
69+
if (isAllModulePathCapable()) {
70+
final Path jmods = Path.of(System.getProperty("java.home"), "jmods");
71+
params.add(new Object[][] { new String[] { "--add-modules", "ALL-MODULE-PATH",
72+
// Since JDK-8345259 ALL-MODULE-PATH requires --module-path arg
73+
"--module-path", jmods.toString() } });
74+
}
75+
return Collections.unmodifiableList(params);
76+
}
77+
78+
private static boolean isAllModulePathCapable() {
79+
Path jmods = Path.of(System.getProperty("java.home"), "jmods");
80+
boolean noJmods = Files.notExists(jmods);
81+
if (LinkableRuntimeImage.isLinkableRuntime() && noJmods) {
82+
TKit.trace("ALL-MODULE-PATH test skipped for linkable run-time image");
83+
return false;
84+
}
85+
return true;
86+
}
87+
5888
@Test
5989
public void testNoArgs() {
6090
List<String> output =
@@ -306,17 +336,12 @@ public void testNoOutputDir(boolean appImage) throws Throwable {
306336
}
307337

308338
@Test
309-
@Parameter("ALL-MODULE-PATH")
310-
@Parameter("ALL-DEFAULT")
311-
@Parameter("java.desktop")
312-
@Parameter("java.desktop,jdk.jartool")
313-
@Parameter({ "java.desktop", "jdk.jartool" })
314-
public void testAddModules(String... addModulesArg) {
339+
@ParameterSupplier("addModulesParams")
340+
public void testAddModules(String[] addModulesArg) {
315341
JPackageCommand cmd = JPackageCommand
316342
.helloAppImage("goodbye.jar:com.other/com.other.Hello")
317343
.ignoreDefaultRuntime(true); // because of --add-modules
318-
Stream.of(addModulesArg).map(v -> Stream.of("--add-modules", v)).flatMap(
319-
s -> s).forEachOrdered(cmd::addArgument);
344+
Stream.of(addModulesArg).forEachOrdered(cmd::addArgument);
320345
cmd.executeAndAssertHelloAppImageCreated();
321346
}
322347

‎test/jdk/tools/jpackage/share/JLinkOptionsTest.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,26 @@ public static Collection input() {
5858
"--jlink-options",
5959
"--strip-debug --no-man-pages --no-header-files",
6060
"--jlink-options",
61-
"--bind-services",
61+
"--verbose --bind-services --limit-modules java.smartcardio,jdk.crypto.cryptoki,java.desktop",
6262
},
63-
// with bind-services should have some services
63+
// with limit-modules and bind-services should have them in the result
6464
new String[]{"java.smartcardio", "jdk.crypto.cryptoki"},
6565
null,
6666
},
6767
// bind-services
6868
{"Hello", new String[]{
69-
"--jlink-options", "--bind-services",
69+
"--jlink-options",
70+
"--bind-services --limit-modules jdk.jartool,jdk.unsupported,java.desktop",
7071
},
71-
// non modular should have everything
72+
// non modular should have at least the module limits
7273
new String[]{"jdk.jartool", "jdk.unsupported"},
7374
null,
7475
},
7576

7677
// jlink-options --bind-services
7778
{"com.other/com.other.Hello", new String[]{
78-
"--jlink-options", "--bind-services",
79+
"--jlink-options",
80+
"--bind-services --limit-modules java.smartcardio,jdk.crypto.cryptoki,java.desktop",
7981
},
8082
// with bind-services should have some services
8183
new String[]{"java.smartcardio", "jdk.crypto.cryptoki"},

‎test/jdk/tools/jpackage/share/RuntimeImageSymbolicLinksTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public class RuntimeImageSymbolicLinksTest {
5252

5353
@Test(ifNotOS = WINDOWS)
5454
public static void test() throws Exception {
55-
final Path jmods = Path.of(System.getProperty("java.home"), "jmods");
5655
final Path workDir = TKit.createTempDirectory("runtime").resolve("data");
5756
final Path jlinkOutputDir = workDir.resolve("temp.runtime");
5857
Files.createDirectories(jlinkOutputDir.getParent());
@@ -62,8 +61,7 @@ public static void test() throws Exception {
6261
.dumpOutput()
6362
.addArguments(
6463
"--output", jlinkOutputDir.toString(),
65-
"--add-modules", "ALL-MODULE-PATH",
66-
"--module-path", jmods.toString(),
64+
"--add-modules", "java.desktop",
6765
"--strip-debug",
6866
"--no-header-files",
6967
"--no-man-pages",

‎test/jdk/tools/jpackage/share/RuntimeImageTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public class RuntimeImageTest {
4444

4545
@Test
4646
public static void test() throws Exception {
47-
final Path jmods = Path.of(System.getProperty("java.home"), "jmods");
4847
final Path workDir = TKit.createTempDirectory("runtime").resolve("data");
4948
final Path jlinkOutputDir = workDir.resolve("temp.runtime");
5049
Files.createDirectories(jlinkOutputDir.getParent());
@@ -54,8 +53,7 @@ public static void test() throws Exception {
5453
.dumpOutput()
5554
.addArguments(
5655
"--output", jlinkOutputDir.toString(),
57-
"--add-modules", "ALL-MODULE-PATH",
58-
"--module-path", jmods.toString(),
56+
"--add-modules", "java.desktop",
5957
"--strip-debug",
6058
"--no-header-files",
6159
"--no-man-pages",

‎test/jdk/tools/jpackage/share/RuntimePackageTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ private static PackageTest init(Set<PackageType> types) {
101101
.forTypes(types)
102102
.addInitializer(cmd -> {
103103
final Path runtimeImageDir;
104-
final Path jmods = Path.of(System.getProperty("java.home"), "jmods");
105104

106105
if (JPackageCommand.DEFAULT_RUNTIME_IMAGE != null) {
107106
runtimeImageDir = JPackageCommand.DEFAULT_RUNTIME_IMAGE;
@@ -113,8 +112,7 @@ private static PackageTest init(Set<PackageType> types) {
113112
.dumpOutput()
114113
.addArguments(
115114
"--output", runtimeImageDir.toString(),
116-
"--add-modules", "ALL-MODULE-PATH",
117-
"--module-path", jmods.toString(),
115+
"--add-modules", "java.desktop",
118116
"--strip-debug",
119117
"--no-header-files",
120118
"--no-man-pages")

0 commit comments

Comments
 (0)