|
57 | 57 | import jdk.graal.compiler.util.json.JsonWriter; |
58 | 58 |
|
59 | 59 | 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 '"; |
60 | 62 |
|
61 | 63 | public static boolean throwMissingRegistrationErrors() { |
62 | 64 | return ThrowMissingRegistrationErrors.hasBeenSet(); |
@@ -196,18 +198,28 @@ protected static String appendUnsatisfiedConditions(String message, RuntimeDynam |
196 | 198 | String paragraphSeparator = lineSeparator + lineSeparator; |
197 | 199 | int splitIndex = message.indexOf(paragraphSeparator); |
198 | 200 | if (splitIndex == -1) { |
199 | | - return message + paragraphSeparator + |
| 201 | + return replaceFirst(message + paragraphSeparator + |
200 | 202 | "Reachability metadata for this access was found, but it is inactive because its runtime conditions were not satisfied." + lineSeparator + |
201 | 203 | "To fix this, either change/remove the metadata condition, or make sure the condition is reached before this access." + lineSeparator + |
202 | 204 | "Unsatisfied runtime conditions:" + paragraphSeparator + |
203 | | - conditions; |
| 205 | + conditions, |
| 206 | + MATCHING_METADATA_HEADER, METADATA_HEADER); |
204 | 207 | } |
205 | | - return message.substring(0, splitIndex) + paragraphSeparator + |
| 208 | + return replaceFirst(message.substring(0, splitIndex) + paragraphSeparator + |
206 | 209 | "Reachability metadata for this access was found, but it is inactive because its runtime conditions were not satisfied." + lineSeparator + |
207 | 210 | "To fix this, either change/remove the metadata condition, or make sure the condition is reached before this access." + lineSeparator + |
208 | 211 | "Unsatisfied runtime conditions:" + paragraphSeparator + |
209 | 212 | 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()); |
211 | 223 | } |
212 | 224 |
|
213 | 225 | protected static ConfigurationType namedConfigurationType(String typeName) { |
|
0 commit comments