Skip to content

Commit

Permalink
Merge pull request #277 from Karm/issues-262-again
Browse files Browse the repository at this point in the history
ImageIO requires -H:+ForeignAPISupport to try to lookup fonts
  • Loading branch information
Karm authored Aug 19, 2024
2 parents ab6f6ff + a218277 commit 9f6c895
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@
import java.util.stream.Stream;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_0;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.LockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.OmitInlinedMethodDebugLineInfo_23_0;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.TrackNodeSourcePosition_23_0;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.UnlockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.DebugCodeInfoUseSourceMappings_23_0;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.ForeignAPISupport_24_2;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.LockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.OmitInlinedMethodDebugLineInfo_23_0;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.TrackNodeSourcePosition_23_0;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.UnlockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.utils.Commands.builderRoutine;
import static org.graalvm.tests.integration.utils.Commands.cleanTarget;
import static org.graalvm.tests.integration.utils.Commands.cleanup;
Expand Down Expand Up @@ -524,7 +525,8 @@ public void imageioAWT(TestInfo testInfo, Apps app) throws IOException, Interrup
// Build
processLog = Path.of(appDir.getAbsolutePath(), "logs", "build-and-run.log").toFile();

builderRoutine(app, report, cn, mn, appDir, processLog);
builderRoutine(0, app.buildAndRunCmds.cmds.length - 1,
app, report, cn, mn, appDir, processLog, null, getSwitches(app));

// Record images' hashsums as created by a Java process
final List<String> errors = new ArrayList<>(12);
Expand Down Expand Up @@ -610,31 +612,40 @@ public void imageioAWT(TestInfo testInfo, Apps app) throws IOException, Interrup

// Test static libs in the executable
final File executable = new File(appDir.getAbsolutePath() + File.separator + "target", "imageio");
Set<String> expected = Set.of("libawt.a", "libawt_headless.a", "libfdlibm.a", "libfontmanager.a", "libjava.a", "libjavajpeg.a", "libjvm.a", "liblcms.a", "liblibchelper.a", "libnet.a", "libnio.a", "libzip.a");
final Set<String> expected = new HashSet<>();
expected.add("libawt.a");
expected.add("libawt_headless.a");
expected.add("libfdlibm.a");
expected.add("libfontmanager.a");
expected.add("libjava.a");
expected.add("libjavajpeg.a");
expected.add("libjvm.a");
expected.add("liblcms.a");
expected.add("liblibchelper.a");
expected.add("libnet.a");
expected.add("libnio.a");
expected.add("libzip.a");
if (UsedVersion.getVersion(inContainer).compareTo(Version.parse("24.2")) >= 0) {
expected.add("libsvm_container.a");
}
if (UsedVersion.getVersion(inContainer).compareTo(Version.parse("23.0")) >= 0) {
// The set of static libs for imageio is smaller beginning with Mandrel 23+ as
// it has dynamic AWT support.
Set<String> modifiable = new HashSet<>(expected);
modifiable.remove("libawt_headless.a");
modifiable.remove("libfontmanager.a");
modifiable.remove("libjavajpeg.a");
modifiable.remove("liblcms.a");
modifiable.remove("libawt.a");
expected = Collections.unmodifiableSet(modifiable);
expected.remove("libawt_headless.a");
expected.remove("libfontmanager.a");
expected.remove("libjavajpeg.a");
expected.remove("liblcms.a");
expected.remove("libawt.a");
}
if (UsedVersion.jdkFeature(inContainer) >= 21) {
// JDK 21 has fdlibm ported to Java. See JDK-8171407
Set<String> modifiable = new HashSet<>(expected);
modifiable.remove("libfdlibm.a");
expected = Collections.unmodifiableSet(modifiable);
expected.remove("libfdlibm.a");
}
if (UsedVersion.jdkFeature(inContainer) > 11 || (UsedVersion.jdkFeature(inContainer) == 11 && UsedVersion.jdkUpdate(inContainer) > 12)) {
// Harfbuzz removed: https://github.com/graalvm/mandrel/issues/286
// NO-OP
} else {
Set<String> modifiable = new HashSet<>(expected);
modifiable.add("libharfbuzz.a");
expected = Collections.unmodifiableSet(modifiable);
expected.add("libharfbuzz.a");
}

final Set<String> actual = listStaticLibs(executable);
Expand Down Expand Up @@ -1047,6 +1058,11 @@ private static Map<String, String> getSwitches(Apps app) {
switches.put(DebugCodeInfoUseSourceMappings_23_0.token, "");
switches.put(OmitInlinedMethodDebugLineInfo_23_0.token, "");
}
if (version.compareTo(Version.create(24, 2, 0)) >= 0) {
switches.put(ForeignAPISupport_24_2.token, ForeignAPISupport_24_2.replacement);
} else {
switches.put(ForeignAPISupport_24_2.token, "");
}
return switches;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_0;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.LockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.OmitInlinedMethodDebugLineInfo_23_0;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.TrackNodeSourcePosition_23_0;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.UnlockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.DebugCodeInfoUseSourceMappings_23_0;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.LockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.OmitInlinedMethodDebugLineInfo_23_0;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.TrackNodeSourcePosition_23_0;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.UnlockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.utils.Commands.CMD_DEFAULT_TIMEOUT_MS;
import static org.graalvm.tests.integration.utils.Commands.CMD_LONG_TIMEOUT_MS;
import static org.graalvm.tests.integration.utils.Commands.CONTAINER_RUNTIME;
Expand Down Expand Up @@ -99,22 +99,6 @@ public class DebugSymbolsTest {
// GOTO i.e. accessing a URL of a debugged test app to trigger a certain code path
private static final long GOTO_URL_SLEEP_MS = 50;

public enum DebugOptions {
UnlockExperimentalVMOptions_23_1("<DEBUG_FLAGS_23_1_a>", "-H:+UnlockExperimentalVMOptions"),
LockExperimentalVMOptions_23_1("<DEBUG_FLAGS_23_1_b>", "-H:-UnlockExperimentalVMOptions"),
TrackNodeSourcePosition_23_0("<DEBUG_FLAGS_23_0_a>", "-H:+TrackNodeSourcePosition"),
DebugCodeInfoUseSourceMappings_23_0("<DEBUG_FLAGS_23_0_b>", "-H:+DebugCodeInfoUseSourceMappings"),
OmitInlinedMethodDebugLineInfo_23_0("<DEBUG_FLAGS_23_0_c>", "-H:+OmitInlinedMethodDebugLineInfo");

public final String token;
final String replacement;

DebugOptions(String token, String replacement) {
this.token = token;
this.replacement = replacement;
}
}

@Test
@Tag("debugSymbolsSmoke")
@DisabledOnOs({OS.WINDOWS, OS.MAC}) // This targets GCC/GDB toolchain specifically.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.graalvm.tests.integration.utils;

public enum AuxiliaryOptions {
UnlockExperimentalVMOptions_23_1("<DEBUG_FLAGS_23_1_a>", "-H:+UnlockExperimentalVMOptions"),
LockExperimentalVMOptions_23_1("<DEBUG_FLAGS_23_1_b>", "-H:-UnlockExperimentalVMOptions"),
TrackNodeSourcePosition_23_0("<DEBUG_FLAGS_23_0_a>", "-H:+TrackNodeSourcePosition"),
DebugCodeInfoUseSourceMappings_23_0("<DEBUG_FLAGS_23_0_b>", "-H:+DebugCodeInfoUseSourceMappings"),
OmitInlinedMethodDebugLineInfo_23_0("<DEBUG_FLAGS_23_0_c>", "-H:+OmitInlinedMethodDebugLineInfo"),
ForeignAPISupport_24_2("<FFAPI>", "-H:+ForeignAPISupport");

public final String token;
public final String replacement;

AuxiliaryOptions(String token, String replacement) {
this.token = token;
this.replacement = replacement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package org.graalvm.tests.integration.utils;

import org.graalvm.tests.integration.DebugSymbolsTest;

import java.io.File;

import static org.graalvm.tests.integration.AppReproducersTest.BASE_DIR;
Expand All @@ -29,6 +27,12 @@
import static org.graalvm.tests.integration.PerfCheckTest.FINAL_NAME_TOKEN;
import static org.graalvm.tests.integration.PerfCheckTest.MX_HEAP_MB;
import static org.graalvm.tests.integration.PerfCheckTest.NATIVE_IMAGE_XMX_GB;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.DebugCodeInfoUseSourceMappings_23_0;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.ForeignAPISupport_24_2;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.LockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.OmitInlinedMethodDebugLineInfo_23_0;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.TrackNodeSourcePosition_23_0;
import static org.graalvm.tests.integration.utils.AuxiliaryOptions.UnlockExperimentalVMOptions_23_1;
import static org.graalvm.tests.integration.utils.Commands.BUILDER_IMAGE;
import static org.graalvm.tests.integration.utils.Commands.CONTAINER_RUNTIME;
import static org.graalvm.tests.integration.utils.Commands.GRAALVM_BUILD_OUTPUT_JSON_FILE;
Expand Down Expand Up @@ -209,7 +213,8 @@ public enum BuildAndRunCmds {
new String[]{"mvn", "clean", "package"},
new String[]{"java", "-Djava.awt.headless=true", "-agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image", "-jar", "target/imageio.jar"},
new String[]{"jar", "uf", "target/imageio.jar", "-C", "src/main/resources/", "META-INF"},
new String[]{"native-image", "-J-Djava.awt.headless=true", "--no-fallback", "-jar", "target/imageio.jar", "target/imageio"},
new String[]{"native-image", UnlockExperimentalVMOptions_23_1.token, ForeignAPISupport_24_2.token, LockExperimentalVMOptions_23_1.token,
"-J-Djava.awt.headless=true", "--no-fallback", "-jar", "target/imageio.jar", "target/imageio"},
new String[]{IS_THIS_WINDOWS ? "target\\imageio.exe" : "./target/imageio", "-Djava.home=.", "-Djava.awt.headless=true"}
}),
IMAGEIO_BUILDER_IMAGE(new String[][]{
Expand All @@ -229,7 +234,7 @@ public enum BuildAndRunCmds {
// Native image build itself (jar was updated with properties in the previous step)
new String[]{CONTAINER_RUNTIME, "run", IS_THIS_WINDOWS ? "" : "-u", IS_THIS_WINDOWS ? "" : getUnixUIDGID(),
"-t", "-v", BASE_DIR + File.separator + "apps" + File.separator + "imageio:/project:z",
BUILDER_IMAGE,
BUILDER_IMAGE, UnlockExperimentalVMOptions_23_1.token, ForeignAPISupport_24_2.token, LockExperimentalVMOptions_23_1.token,
"-J-Djava.awt.headless=true", "--no-fallback", "-jar", "target/imageio.jar", "target/imageio"},
// We build a runtime image, ubi 8 minimal based, runtime dependencies installed
new String[]{CONTAINER_RUNTIME, "build", "--network=host", "-t", ContainerNames.IMAGEIO_BUILDER_IMAGE.name, "."},
Expand All @@ -246,12 +251,12 @@ public enum BuildAndRunCmds {
:
new String[]{"unzip", "test_data.txt.zip", "-d", "target"},

new String[] { "native-image", DebugSymbolsTest.DebugOptions.UnlockExperimentalVMOptions_23_1.token,
new String[] { "native-image", UnlockExperimentalVMOptions_23_1.token,
"-H:GenerateDebugInfo=" + (IS_THIS_MACOS ? "0" : "1"), "-H:+PreserveFramePointer", "-H:-DeleteLocalSymbols",
DebugSymbolsTest.DebugOptions.TrackNodeSourcePosition_23_0.token,
DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_0.token,
DebugSymbolsTest.DebugOptions.OmitInlinedMethodDebugLineInfo_23_0.token,
DebugSymbolsTest.DebugOptions.LockExperimentalVMOptions_23_1.token,
TrackNodeSourcePosition_23_0.token,
DebugCodeInfoUseSourceMappings_23_0.token,
OmitInlinedMethodDebugLineInfo_23_0.token,
LockExperimentalVMOptions_23_1.token,
"-jar", "target/debug-symbols-smoke.jar", "target/debug-symbols-smoke" },
new String[]{"java", "-jar", "./target/debug-symbols-smoke.jar"},
new String[]{IS_THIS_WINDOWS ? "target\\debug-symbols-smoke.exe" : "./target/debug-symbols-smoke"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public Pattern[] get(boolean inContainer) {
// org.jfree.jfreesvg reflectively accesses com.orsoncharts.Chart3DHints which is not on the classpath
Pattern.compile("Warning: Could not resolve .*com.orsoncharts.Chart3DHints for reflection configuration. Reason: java.lang.ClassNotFoundException: com.orsoncharts.Chart3DHints."),
// The java agent erroneously produces a reflection config mentioning this constructor, which doesn't exist
Pattern.compile("Warning: Method sun\\.security\\.provider\\.NativePRNG\\.<init>\\(SecureRandomParameters\\) not found.")
Pattern.compile("Warning: Method sun\\.security\\.provider\\.NativePRNG\\.<init>\\(SecureRandomParameters\\) not found."),
// https://github.com/graalvm/mandrel/issues/760
Pattern.compile(".*Warning: Option 'DynamicProxyConfigurationResources' is deprecated.*"),
};
}
},
Expand Down

0 comments on commit 9f6c895

Please sign in to comment.