Skip to content

Commit ecabbc2

Browse files
committed
Updates to sapmachine jlink plugin
1 parent e8b3b0f commit ecabbc2

File tree

5 files changed

+35
-45
lines changed

5 files changed

+35
-45
lines changed

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/AddSapMachineTools.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2025, SAP SE. All rights reserved.
2+
* Copyright (c) 2025 SAP SE. 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
@@ -25,27 +25,21 @@
2525

2626
package jdk.tools.jlink.internal.plugins;
2727

28+
import java.io.IOException;
2829
import java.io.UncheckedIOException;
29-
import java.nio.charset.StandardCharsets;
3030
import java.nio.file.Files;
3131
import java.nio.file.Path;
32-
import java.nio.file.StandardCopyOption;
3332
import java.util.List;
34-
import java.util.Locale.Category;
35-
import java.util.Map;
36-
import java.util.function.Function;
37-
import java.io.IOException;
3833

3934
import jdk.tools.jlink.internal.ExecutableImage;
40-
import jdk.tools.jlink.internal.PostProcessor;
4135
import jdk.tools.jlink.internal.Platform;
36+
import jdk.tools.jlink.internal.PostProcessor;
4237
import jdk.tools.jlink.plugin.PluginException;
4338
import jdk.tools.jlink.plugin.ResourcePool;
4439
import jdk.tools.jlink.plugin.ResourcePoolBuilder;
45-
import jdk.tools.jlink.plugin.ResourcePoolEntry;
4640

4741
/**
48-
* Adds tools that are SapMachine specific tools
42+
* Adds tools that are SapMachine specific
4943
*/
5044
public class AddSapMachineTools extends AbstractPlugin implements PostProcessor {
5145

@@ -68,9 +62,15 @@ public boolean hasRawArgument() {
6862
return false;
6963
}
7064

71-
private final String tools = "lib/" + System.mapLibraryName("asyncProfiler") + " bin/asprof lib/async-profiler.jar lib/converter.jar legal/async/CHANGELOG.md legal/async/LICENSE legal/async/README.md";
72-
73-
private Path javaHomeFolder;
65+
private final String[] tools = {
66+
"lib/" + System.mapLibraryName("asyncProfiler"),
67+
"bin/asprof",
68+
"lib/async-profiler.jar",
69+
"lib/converter.jar",
70+
"legal/async/CHANGELOG.md",
71+
"legal/async/LICENSE",
72+
"legal/async/README.md"
73+
};
7474

7575
@Override
7676
public List<String> process(ExecutableImage image) {
@@ -86,26 +86,24 @@ public List<String> process(ExecutableImage image) {
8686
var sourceJavaHome = Path.of(System.getProperty("java.home"));
8787
var targetJavaHome = image.getHome();
8888

89-
for (String tool : tools.split(" ")) {
89+
for (String tool : tools) {
9090
var path = sourceJavaHome.resolve(tool);
9191
var target = targetJavaHome.resolve(tool);
9292
if (Files.exists(path)) {
9393
try {
9494
Files.createDirectories(target.getParent());
95-
Files.createFile(target);
96-
Files.copy(path, target, StandardCopyOption.REPLACE_EXISTING);
95+
Files.copy(path, target);
9796
} catch (IOException e) {
9897
throw new UncheckedIOException(e);
9998
}
10099
}
101100
}
102101

103-
return List.of();
102+
return null;
104103
}
105104

106105
@Override
107106
public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
108107
return in;
109108
}
110-
111109
}

src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ Invalid language tag: %s
287287
include-locales.localedatanotfound=\
288288
jdk.localedata module was not specified with --add-modules option
289289

290+
# SapMachine 2025-09-01: SapMachine tools plugin
290291
add-sapmachine-tools.description=\
291292
Add SapMachine specific tools to the image.
292293

src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins_de.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ include-locales.invalidtag=Ungültiges Sprachtag: %s
158158

159159
include-locales.localedatanotfound=Modul jdk.localedata wurde mit der Option --add-modules nicht angegeben
160160

161+
# SapMachine 2025-09-01: SapMachine tools plugin
162+
add-sapmachine-tools.description=Fügt SapMachine-spezifische Tools zum Image hinzu.
163+
164+
add-sapmachine-tools.usage=\ --add-sapmachine-tools Fügt SapMachine-spezifische Tools zum Image hinzu.
165+
161166
main.status.ok=Funktional.
162167

163168
main.status.not.ok= Nicht funktional.

src/jdk.jlink/share/classes/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
jdk.tools.jlink.internal.plugins.VendorVMBugURLPlugin,
8585
jdk.tools.jlink.internal.plugins.VendorVersionPlugin,
8686
jdk.tools.jlink.internal.plugins.CDSPlugin,
87+
// SapMachine 2025-01-09: SapMachine tools plugin
8788
jdk.tools.jlink.internal.plugins.AddSapMachineTools,
8889
jdk.tools.jlink.internal.plugins.SaveJlinkArgfilesPlugin;
8990
}
Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2025, SAP SE. All rights reserved.
2+
* Copyright (c) 2025 SAP SE. 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
@@ -21,62 +21,47 @@
2121
* questions.
2222
*/
2323

24-
import java.io.File;
2524
import java.nio.file.Files;
2625
import java.nio.file.Path;
2726

28-
import jdk.test.lib.JDKToolFinder;
29-
import jdk.test.lib.Platform;
30-
import jdk.test.lib.process.*;
31-
import jdk.test.whitebox.WhiteBox;
27+
import jtreg.SkippedException;
3228

3329
import tests.Helper;
3430

35-
import jtreg.SkippedException;
36-
3731
/* @test
38-
* @bug 8264322
3932
* @summary Test the --add-sapmachine-tools plugin
40-
* @requires os.family == "linux" | os.family == "mac"
4133
* @library ../../lib
4234
* @library /test/lib
4335
* @modules java.base/jdk.internal.jimage
44-
* jdk.jlink/jdk.tools.jlink.internal
45-
* jdk.jlink/jdk.tools.jmod
4636
* jdk.jlink/jdk.tools.jimage
47-
* jdk.compiler
48-
* @build tests.*
49-
* @build jdk.test.whitebox.WhiteBox
50-
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
51-
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. CDSPluginTest
37+
* @run main AddSapMachineToolsTest
5238
*/
5339

5440
public class AddSapMachineToolsTest {
5541
public static void main(String[] args) throws Throwable {
5642

5743
Helper helper = Helper.newHelper();
5844
if (helper == null) {
59-
System.err.println("Test not run");
6045
return;
6146
}
6247

6348
var sourceJavaHome = Path.of(System.getProperty("java.home"));
6449

6550
if (!Files.exists(sourceJavaHome.resolve("lib/async-profiler.jar"))) {
66-
System.err.println("Test not run, async-profiler not configured");
67-
return;
51+
throw new SkippedException("Test not run, async-profiler not in base image.");
6852
}
6953

7054
var module = "sapmachine.tools";
7155
helper.generateDefaultJModule(module);
72-
var image = helper.generateDefaultImage(new String[] { "--add-sapmachine-tools" },
73-
module)
74-
.assertSuccess();
75-
76-
String subDir = "lib/server/";
56+
var image = helper
57+
.generateDefaultImage(new String[] { "--add-sapmachine-tools" }, module)
58+
.assertSuccess();
7759

7860
helper.checkImage(image, module, null, null,
79-
new String[] { "lib/async-profiler.jar", "lib/converter.jar",
80-
"lib/" + System.mapLibraryName("asyncProfiler")});
61+
new String[] {
62+
"lib/" + System.mapLibraryName("asyncProfiler"),
63+
"bin/asprof",
64+
"lib/async-profiler.jar",
65+
"lib/converter.jar"});
8166
}
8267
}

0 commit comments

Comments
 (0)