Skip to content

Commit fbcc535

Browse files
committed
[GR-73955] Clarify conditional metadata diagnostics
1 parent a30e7a5 commit fbcc535

2 files changed

Lines changed: 16 additions & 468 deletions

File tree

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
import jdk.graal.compiler.util.json.JsonWriter;
5858

5959
public class MissingRegistrationUtils {
60+
private static final String MATCHING_METADATA_HEADER = "The matching metadata element in the '";
61+
private static final String METADATA_HEADER = "The metadata element in the '";
6062

6163
public static boolean throwMissingRegistrationErrors() {
6264
return ThrowMissingRegistrationErrors.hasBeenSet();
@@ -196,18 +198,28 @@ protected static String appendUnsatisfiedConditions(String message, RuntimeDynam
196198
String paragraphSeparator = lineSeparator + lineSeparator;
197199
int splitIndex = message.indexOf(paragraphSeparator);
198200
if (splitIndex == -1) {
199-
return message + paragraphSeparator +
201+
return replaceFirst(message + paragraphSeparator +
200202
"Reachability metadata for this access was found, but it is inactive because its runtime conditions were not satisfied." + lineSeparator +
201203
"To fix this, either change/remove the metadata condition, or make sure the condition is reached before this access." + lineSeparator +
202204
"Unsatisfied runtime conditions:" + paragraphSeparator +
203-
conditions;
205+
conditions,
206+
MATCHING_METADATA_HEADER, METADATA_HEADER);
204207
}
205-
return message.substring(0, splitIndex) + paragraphSeparator +
208+
return replaceFirst(message.substring(0, splitIndex) + paragraphSeparator +
206209
"Reachability metadata for this access was found, but it is inactive because its runtime conditions were not satisfied." + lineSeparator +
207210
"To fix this, either change/remove the metadata condition, or make sure the condition is reached before this access." + lineSeparator +
208211
"Unsatisfied runtime conditions:" + paragraphSeparator +
209212
conditions + paragraphSeparator +
210-
message.substring(splitIndex + paragraphSeparator.length());
213+
message.substring(splitIndex + paragraphSeparator.length()),
214+
MATCHING_METADATA_HEADER, METADATA_HEADER);
215+
}
216+
217+
private static String replaceFirst(String text, String oldValue, String newValue) {
218+
int index = text.indexOf(oldValue);
219+
if (index == -1) {
220+
return text;
221+
}
222+
return text.substring(0, index) + newValue + text.substring(index + oldValue.length());
211223
}
212224

213225
protected static ConfigurationType namedConfigurationType(String typeName) {

0 commit comments

Comments
 (0)