Skip to content

Commit e31afe7

Browse files
committed
Ensure methods from SubstrateOptionsParser are usable in driver
1 parent 7e6da64 commit e31afe7

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/OptionUtils.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
import com.oracle.svm.core.SubstrateUtil;
3838
import com.oracle.svm.core.option.LocatableMultiOptionValue.ValueWithOrigin;
39-
import com.oracle.svm.core.util.UserError;
4039

4140
import jdk.graal.compiler.options.OptionDescriptor;
4241
import jdk.graal.compiler.options.OptionKey;
@@ -60,14 +59,14 @@ private static Stream<? extends String> resolveOptionValueRedirection(OptionKey<
6059
if (entry.trim().startsWith("@")) {
6160
Path valuesFile = Path.of(entry.substring(1));
6261
if (valuesFile.isAbsolute()) {
63-
throw UserError.abort("Option '%s' provided by %s contains value redirection file '%s' that is an absolute path.",
64-
SubstrateOptionsParser.commandArgument(option, optionValue), origin, valuesFile);
62+
throw new AssertionError("Option '" + SubstrateOptionsParser.commandArgument(option, optionValue) + "' provided by " + origin +
63+
" contains value redirection file '" + valuesFile + "' that is an absolute path.");
6564
}
6665
try {
6766
return origin.getRedirectionValues(valuesFile).stream();
6867
} catch (IOException e) {
69-
throw UserError.abort(e, "Option '%s' provided by %s contains invalid option value redirection.",
70-
SubstrateOptionsParser.commandArgument(option, optionValue), origin);
68+
throw new AssertionError("Option '" + SubstrateOptionsParser.commandArgument(option, optionValue) + "' provided by " + origin +
69+
" contains invalid option value redirection.", e);
7170
}
7271
} else {
7372
return Stream.of(entry);

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/SubstrateOptionsParser.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import com.oracle.svm.common.option.CommonOptionParser.OptionParseResult;
4242
import com.oracle.svm.common.option.UnsupportedOptionClassException;
4343
import com.oracle.svm.core.util.InterruptImageBuilding;
44-
import com.oracle.svm.core.util.VMError;
4544
import com.oracle.svm.util.LogUtils;
4645

4746
import jdk.graal.compiler.options.OptionDescriptor;
@@ -63,8 +62,7 @@ static OptionParseResult parseOption(EconomicMap<String, OptionDescriptor> optio
6362
try {
6463
return CommonOptionParser.parseOption(options, isHosted, option, valuesMap, optionPrefix, booleanOptionFormat);
6564
} catch (UnsupportedOptionClassException e) {
66-
VMError.shouldNotReachHere(e.getMessage());
67-
return null;
65+
throw new AssertionError("Should not reach here", e);
6866
}
6967
}
7068

@@ -160,7 +158,6 @@ public static double parseDouble(String v) {
160158
* @return recommendation for setting a option value (e.g., for option 'Name' and value 'file'
161159
* it returns "-H:Name=file")
162160
*/
163-
@Platforms(Platform.HOSTED_ONLY.class)
164161
public static String commandArgument(OptionKey<?> option, String value) {
165162
return commandArgument(option, value, null);
166163
}
@@ -175,7 +172,6 @@ public static String commandArgument(OptionKey<?> option, String value) {
175172
* @return recommendation for setting a option value (e.g., for option 'Name' and value 'file'
176173
* it returns "-H:Name=file")
177174
*/
178-
@Platforms(Platform.HOSTED_ONLY.class)
179175
public static String commandArgument(OptionKey<?> option, String value, String apiOptionName) {
180176
/* Ensure descriptor is loaded */
181177
OptionDescriptor optionDescriptor = option.loadDescriptor();
@@ -193,7 +189,9 @@ public static String commandArgument(OptionKey<?> option, String value, String a
193189
}
194190

195191
if (optionDescriptor.getOptionValueType() == Boolean.class) {
196-
VMError.guarantee(value.equals("+") || value.equals("-"), "Boolean option value can be only + or -");
192+
if (!value.equals("+") && !value.equals("-")) {
193+
throw new AssertionError("Boolean option value can be only + or -");
194+
}
197195
for (APIOption apiOption : apiOptions) {
198196
String selected = selectVariant(apiOption, apiOptionName);
199197
if (selected != null) {
@@ -240,12 +238,10 @@ public static String commandArgument(OptionKey<?> option, String value, String a
240238
}
241239
}
242240

243-
@Platforms(Platform.HOSTED_ONLY.class)
244241
public static String commandArgument(OptionKey<?> option, String value, String apiOptionName, boolean escape, boolean newLine) {
245242
return formatCommandArgument(commandArgument(option, value, apiOptionName), escape, newLine);
246243
}
247244

248-
@Platforms(Platform.HOSTED_ONLY.class)
249245
public static String commandArgument(OptionKey<?> option, String value, boolean escape, boolean newLine) {
250246
return formatCommandArgument(commandArgument(option, value), escape, newLine);
251247
}
@@ -262,7 +258,9 @@ private static String formatCommandArgument(String optionMessage, boolean escape
262258
}
263259

264260
private static String selectVariant(APIOption apiOption, String apiOptionName) {
265-
VMError.guarantee(apiOption.name().length > 0, "APIOption requires at least one name");
261+
if (apiOption.name().length <= 0) {
262+
throw new AssertionError("APIOption requires at least one name");
263+
}
266264
if (!apiOption.deprecated().equals("")) {
267265
return null; /* Never select deprecated API options. */
268266
}

0 commit comments

Comments
 (0)