Skip to content

Commit 655d0a0

Browse files
OracleLabsAutomationelkorchi
authored andcommitted
[GR-58920] Backport to 24.1: Make missing registration warn mode stack trace length customizable
PullRequest: graal/19287
2 parents 7194373 + 50e09fa commit 655d0a0

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

substratevm/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This changelog summarizes major changes to GraalVM Native Image.
44

5+
## GraalVM for JDK 23 (Internal Version 24.1.2)
6+
* (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.
7+
58
## GraalVM for JDK 23 (Internal Version 24.1.0)
69
* (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.
710
* (GR-51106) Fields that are accessed via a `VarHandle` or `MethodHandle` are no longer marked as "unsafe accessed" when the `VarHandle`/`MethodHandle` can be fully intrinsified.

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

+3-4
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

+3
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,9 @@ public enum ReportingMode {
11531153
public static final RuntimeOptionKey<ReportingMode> MissingRegistrationReportingMode = new RuntimeOptionKey<>(
11541154
ReportingMode.Throw);
11551155

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

0 commit comments

Comments
 (0)