Skip to content

Commit d2fb880

Browse files
authored
Fix jlink image warnings (#1143)
* Use correct value with jlink --compress option for Java 21+ * Handle class list file format change in Java 21 * Enable a couple linker integration tests * Update Java version to 17.0.12
1 parent d85e730 commit d2fb880

File tree

6 files changed

+33
-14
lines changed

6 files changed

+33
-14
lines changed

.github/actions/common/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ runs:
8585
if: ${{ inputs.native-image == 'true' }}
8686
uses: graalvm/[email protected]
8787
with:
88-
java-version: ${{ env.JAVA_VERSION }}
89-
version: ${{ env.GRAALVM_VERSION }}
88+
java-version: ${{ env.GRAALVM_VERSION || env.JAVA_VERSION }}
9089
components: 'native-image'
9190
check-for-updates: 'false'
9291
set-java-home: 'false'

.github/workflows/validate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ on:
2929
default: ''
3030

3131
env:
32-
JAVA_VERSION: 17
32+
JAVA_VERSION: 17.0.12
3333
JAVA_DISTRO: oracle
34-
GRAALVM_VERSION: 21.3.3.1
34+
GRAALVM_VERSION: 21.0.7
3535
MVN_ARGS: |
3636
-B -fae -e
3737
-Dmaven.wagon.httpconnectionManager.ttlSeconds=60

linker/src/main/java/io/helidon/build/linker/ClassDataSharing.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
import java.util.Collection;
2727
import java.util.List;
2828
import java.util.concurrent.TimeUnit;
29+
import java.util.stream.Collectors;
2930

3031
import io.helidon.build.common.OSType;
3132
import io.helidon.build.common.PrintStreams;
@@ -370,7 +371,19 @@ private void buildCdsArchive() throws Exception {
370371
}
371372

372373
private List<String> loadClassList() throws IOException {
373-
return Files.readAllLines(classListFile);
374+
return Files.readAllLines(classListFile).stream()
375+
.filter(ClassDataSharing.Builder::isNotComment)
376+
.map(ClassDataSharing.Builder::head)
377+
.collect(Collectors.toList());
378+
}
379+
380+
private static String head(String s) {
381+
// Get first field in string. Assume whitespace delimiter
382+
return s.split("\\s+")[0];
383+
}
384+
385+
private static boolean isNotComment(String s) {
386+
return !s.startsWith("# ");
374387
}
375388

376389
private void execute(String action, String... jvmArgs) throws Exception {

linker/src/main/java/io/helidon/build/linker/Linker.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -193,7 +193,13 @@ private void buildJlinkArguments() {
193193
jlinkArgs.add("--no-header-files");
194194
jlinkArgs.add("--no-man-pages");
195195
jlinkArgs.add("--compress");
196-
jlinkArgs.add("2");
196+
197+
// The options used with --compress changed in 21
198+
if (config.jdk().version().feature() >= 21) {
199+
jlinkArgs.add("zip-6");
200+
} else {
201+
jlinkArgs.add("2");
202+
}
197203

198204
// user provided args
199205
jlinkArgs.addAll(config.additionalJlinkArgs());

linker/src/test/java/io/helidon/build/linker/ClassDataSharingTestIT.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,10 +25,11 @@
2525
import io.helidon.build.common.test.utils.TestLogLevel;
2626

2727
import org.junit.jupiter.api.BeforeAll;
28-
import org.junit.jupiter.api.Disabled;
2928
import org.junit.jupiter.api.Order;
3029
import org.junit.jupiter.api.Tag;
30+
import org.junit.jupiter.api.condition.DisabledOnOs;
3131
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
32+
import org.junit.jupiter.api.condition.OS;
3233
import org.junit.jupiter.params.ParameterizedTest;
3334

3435
import static io.helidon.build.common.FileUtils.javaHome;
@@ -57,9 +58,11 @@ static void setup() {
5758
}
5859

5960
@Tag("mp")
60-
@Disabled("https://github.com/oracle/helidon-build-tools/issues/537")
6161
@ParameterizedTest
6262
@ConfigurationParameterSource("basedir")
63+
// ClassDataSharing uses relativize with jri location and mainJar.
64+
// relativize on Windows requires a shared root which is not true for this test.
65+
@DisabledOnOs(OS.WINDOWS)
6366
void testQuickstartMp(String basedir) throws Exception {
6467
Path mainJar = Path.of(basedir).resolve("target/quickstart-mp.jar");
6568
Path archiveFile = Files.createTempFile("start", "jsa");

linker/src/test/java/io/helidon/build/linker/LinkerTestIT.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
2626
import io.helidon.build.linker.util.Constants;
2727
import io.helidon.build.linker.util.JavaRuntime;
2828

29-
import org.junit.jupiter.api.Disabled;
3029
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
3130
import org.junit.jupiter.api.Order;
3231
import org.junit.jupiter.api.Tag;
@@ -124,7 +123,6 @@ void testQuickstartSe(String basedir) throws Exception {
124123
}
125124

126125
@Tag("mp")
127-
@Disabled("https://github.com/oracle/helidon-build-tools/issues/537")
128126
@Order(4)
129127
@ParameterizedTest
130128
@ConfigurationParameterSource("basedir")

0 commit comments

Comments
 (0)