Skip to content

Commit 8327f69

Browse files
committed
Avoid disabling LoggingFeature for fop benchmark.
1 parent 577d865 commit 8327f69

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

substratevm/mx.substratevm/mx_substratevm_benchmark.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import os
3232
import re
3333
from glob import glob
34+
import tempfile
3435

3536
import zipfile
3637
import mx
@@ -472,6 +473,12 @@ def collect_unique_dependencies(self, path, benchmark, exclude_libs):
472473
return deps
473474

474475

476+
def _empty_file():
477+
with tempfile.NamedTemporaryFile(delete=False) as empty_file:
478+
empty_file.write(b"")
479+
return empty_file.name
480+
481+
475482
# Note: If you wish to preserve the underlying benchmark stderr and stdout files after a run, you can pass the following argument: -preserve
476483
# This argument can be added to either:
477484
# 1. The agent stage: -Dnative-image.benchmark.extra-agent-run-arg=-preserve
@@ -490,13 +497,17 @@ def collect_unique_dependencies(self, path, benchmark, exclude_libs):
490497
'xalan': ['--report-unsupported-elements-at-runtime',
491498
'--initialize-at-build-time=org.apache.crimson.parser.Parser2'],
492499
# There are two main issues with fop:
493-
# 1. LoggingFeature is enabled by default, causing the LogManager configuration to be parsed at build-time. However, DaCapo Harness sets the logging config file path system property at runtime.
494-
# This causes us to incorrectly parse the default log configuration, leading to output on stderr.
500+
# 1. LoggingFeature is enabled by default, causing the LogManager configuration to be parsed at build-time. However
501+
# DaCapo Harness sets the `java.util.logging.config.file` property at run-time. Therefore, we set
502+
# `java.util.logging.config.file` to an empty file to avoid incorrectly parsing the default log configuration,
503+
# leading to output on stderr. We cannot set it to scratch/fop.log as it would normally be, because the file does
504+
# not exist and would fail the benchmark when assertions are enabled.
495505
# 2. Native-image picks a different service provider than the JVM for javax.xml.transform.TransformerFactory.
496506
# We can simply remove the jar containing that provider as it is not required for the benchmark to run.
497507
'fop': ['--allow-incomplete-classpath',
498508
'--report-unsupported-elements-at-runtime',
499-
'-H:-EnableLoggingFeature',
509+
'-esa', '-ea',
510+
f"-Djava.util.logging.config.file={_empty_file()}",
500511
'--initialize-at-run-time=org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList'],
501512
'batik': ['--allow-incomplete-classpath']
502513
}

0 commit comments

Comments
 (0)