Skip to content

Commit c5bf713

Browse files
committed
Make missing registration warn mode stack trace length customizable
1 parent 8798480 commit c5bf713

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
@@ -10,6 +10,7 @@ At runtime, premain runtime options are set along with main class' arguments in
1010
* (GR-48384) Added a GDB Python script (`gdb-debughelpers.py`) to improve the Native Image debugging experience.
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.
13+
* (GR-58383) The length of the printed stack trace when using `-XX:MissingRegistrationReportingMode=Warn` can now be set with `-XX:MissingRegistrationWarnContextLines=`
1314

1415
## GraalVM for JDK 23 (Internal Version 24.1.0)
1516
* (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
@@ -1243,6 +1243,9 @@ public enum ReportingMode {
12431243
public static final RuntimeOptionKey<ReportingMode> MissingRegistrationReportingMode = new RuntimeOptionKey<>(
12441244
ReportingMode.Throw);
12451245

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

0 commit comments

Comments
 (0)