Skip to content

Commit 8fe7df1

Browse files
committed
Make missing registration warn mode stack trace length customizable
1 parent 1edb16b commit 8fe7df1

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

substratevm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ At runtime, premain runtime options are set along with main class' arguments in
1111
* (GR-49517) Add support for emitting Windows x64 unwind info. This enables stack walking in native tooling such as debuggers and profilers.
1212
* (GR-57384) Preserve the origin of a resource included in a native image. The information is included in the report produced by -H:+GenerateEmbeddedResourcesFile.
1313
* (GR-58000) Support for `GetStringUTFLengthAsLong` added in JNI_VERSION_24 ([JDK-8328877](https://bugs.openjdk.org/browse/JDK-8328877))
14+
* (GR-58383) The length of the printed stack trace when using `-XX:MissingRegistrationReportingMode=Warn` can now be set with `-XX:MissingRegistrationWarnContextLines=` and its default length is now 8.
1415

1516
## GraalVM for JDK 23 (Internal Version 24.1.0)
1617
* (GR-51520) The old class initialization strategy, which was deprecated in GraalVM for JDK 22, is removed. The option `StrictImageHeap` no longer has any effect.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/MissingRegistrationUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public static SubstrateOptions.ReportingMode missingRegistrationReportingMode()
4343
return SubstrateOptions.MissingRegistrationReportingMode.getValue();
4444
}
4545

46-
private static final int CONTEXT_LINES = 4;
47-
4846
private static final AtomicReference<Set<String>> seenOutputs = new AtomicReference<>(null);
4947

5048
public static void report(Error exception, StackTraceElement responsibleClass) {
@@ -88,14 +86,15 @@ public static void report(Error exception, StackTraceElement responsibleClass) {
8886
printLine(sb, stackTraceElement);
8987
printed++;
9088
}
91-
if (printed >= CONTEXT_LINES) {
89+
if (printed >= SubstrateOptions.MissingRegistrationWarnContextLines.getValue()) {
9290
break;
9391
}
9492
}
9593
if (seenOutputs.get() == null && seenOutputs.compareAndSet(null, ConcurrentHashMap.newKeySet())) {
9694
/* First output, we print an explanation message */
9795
System.out.println("Note: this run will print partial stack traces of the locations where a " + exception.getClass().toString() + " would be thrown " +
98-
"when the -H:+ThrowMissingRegistrationErrors option is set. The trace stops at the first entry of JDK code and provides " + CONTEXT_LINES + " lines of context.");
96+
"when the -H:+ThrowMissingRegistrationErrors option is set. The trace stops at the first entry of JDK code and provides " +
97+
SubstrateOptions.MissingRegistrationWarnContextLines.getValue() + " lines of context.");
9998
}
10099
String output = sb.toString();
101100
if (seenOutputs.get().add(output)) {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,9 @@ public enum ReportingMode {
12491249
public static final RuntimeOptionKey<ReportingMode> MissingRegistrationReportingMode = new RuntimeOptionKey<>(
12501250
ReportingMode.Throw);
12511251

1252+
@Option(help = "Number of context lines printed for each missing registration error in Warn mode")//
1253+
public static final RuntimeOptionKey<Integer> MissingRegistrationWarnContextLines = new RuntimeOptionKey<>(8);
1254+
12521255
@Option(help = "Instead of warning, throw IOExceptions for link-at-build-time resources at build time")//
12531256
public static final HostedOptionKey<Boolean> ThrowLinkAtBuildTimeIOExceptions = new HostedOptionKey<>(false);
12541257

0 commit comments

Comments
 (0)