2626
2727import org .graalvm .collections .EconomicMap ;
2828
29+ import com .oracle .svm .common .option .MultiOptionValue ;
30+
2931import jdk .graal .compiler .options .OptionKey ;
3032import jdk .graal .compiler .options .OptionValues ;
3133
3234public class HostedOptionCustomizer implements HostedOptionProvider {
33-
3435 private final EconomicMap <OptionKey <?>, Object > hostedValues ;
3536 private final EconomicMap <OptionKey <?>, Object > runtimeValues ;
3637
37- public HostedOptionCustomizer (HostedOptionProvider original ) {
38- hostedValues = OptionValues .newOptionMap ();
39- hostedValues .putAll (original .getHostedValues ());
40-
41- runtimeValues = OptionValues .newOptionMap ();
42- runtimeValues .putAll (original .getRuntimeValues ());
38+ public HostedOptionCustomizer (HostedOptionParser hostedOptionParser ) {
39+ this .hostedValues = copyOptionValues (hostedOptionParser .getHostedValues ());
40+ this .runtimeValues = copyOptionValues (hostedOptionParser .getRuntimeValues ());
4341 }
4442
4543 @ Override
@@ -51,4 +49,18 @@ public EconomicMap<OptionKey<?>, Object> getHostedValues() {
5149 public EconomicMap <OptionKey <?>, Object > getRuntimeValues () {
5250 return runtimeValues ;
5351 }
52+
53+ private static EconomicMap <OptionKey <?>, Object > copyOptionValues (EconomicMap <OptionKey <?>, Object > original ) {
54+ EconomicMap <OptionKey <?>, Object > result = OptionValues .newOptionMap ();
55+ var cursor = original .getEntries ();
56+ while (cursor .advance ()) {
57+ OptionKey <?> key = cursor .getKey ();
58+ Object value = cursor .getValue ();
59+ if (value instanceof MultiOptionValue <?> v ) {
60+ value = v .createCopy ();
61+ }
62+ result .put (key , value );
63+ }
64+ return result ;
65+ }
5466}
0 commit comments