@@ -93,23 +93,17 @@ public void write(String s, byte[] bytes) {
9393 overallCatch .invokeStaticMethod (BUILD_TIME_INITIALIZATION ,
9494 overallCatch .marshalAsArray (String .class , overallCatch .load ("" ))); // empty string means initialize everything
9595
96+ ResultHandle graalVMVersion = overallCatch .invokeStaticMethod (GRAALVM_VERSION_GET_CURRENT );
97+ // Set the user.language and user.country system properties to the default locale
9698 // The deprecated option takes precedence for users who are already using it.
9799 if (nativeConfig .userLanguage ().isPresent ()) {
98100 overallCatch .invokeStaticMethod (REGISTER_RUNTIME_SYSTEM_PROPERTIES ,
99101 overallCatch .load ("user.language" ), overallCatch .load (nativeConfig .userLanguage ().get ()));
100- if (nativeConfig .userCountry ().isPresent ()) {
101- overallCatch .invokeStaticMethod (REGISTER_RUNTIME_SYSTEM_PROPERTIES ,
102- overallCatch .load ("user.country" ), overallCatch .load (nativeConfig .userCountry ().get ()));
103- }
104102 } else if (localesBuildTimeConfig .defaultLocale .isPresent ()) {
105103 overallCatch .invokeStaticMethod (REGISTER_RUNTIME_SYSTEM_PROPERTIES ,
106104 overallCatch .load ("user.language" ),
107105 overallCatch .load (localesBuildTimeConfig .defaultLocale .get ().getLanguage ()));
108- overallCatch .invokeStaticMethod (REGISTER_RUNTIME_SYSTEM_PROPERTIES ,
109- overallCatch .load ("user.country" ),
110- overallCatch .load (localesBuildTimeConfig .defaultLocale .get ().getCountry ()));
111106 } else {
112- ResultHandle graalVMVersion = overallCatch .invokeStaticMethod (GRAALVM_VERSION_GET_CURRENT );
113107 BranchResult graalVm24_2Test = overallCatch
114108 .ifGreaterEqualZero (overallCatch .invokeVirtualMethod (GRAALVM_VERSION_COMPARE_TO , graalVMVersion ,
115109 overallCatch .marshalAsArray (int .class , overallCatch .load (24 ), overallCatch .load (2 ))));
@@ -118,6 +112,22 @@ public void write(String s, byte[] bytes) {
118112 greaterEqual24_2 .invokeStaticMethod (REGISTER_RUNTIME_SYSTEM_PROPERTIES ,
119113 greaterEqual24_2 .load ("user.language" ),
120114 greaterEqual24_2 .load ("en" ));
115+ }
116+ }
117+ // The deprecated option takes precedence for users who are already using it.
118+ if (nativeConfig .userCountry ().isPresent ()) {
119+ overallCatch .invokeStaticMethod (REGISTER_RUNTIME_SYSTEM_PROPERTIES ,
120+ overallCatch .load ("user.country" ), overallCatch .load (nativeConfig .userCountry ().get ()));
121+ } else if (localesBuildTimeConfig .defaultLocale .isPresent ()) {
122+ overallCatch .invokeStaticMethod (REGISTER_RUNTIME_SYSTEM_PROPERTIES ,
123+ overallCatch .load ("user.country" ),
124+ overallCatch .load (localesBuildTimeConfig .defaultLocale .get ().getCountry ()));
125+ } else {
126+ BranchResult graalVm24_2Test = overallCatch
127+ .ifGreaterEqualZero (overallCatch .invokeVirtualMethod (GRAALVM_VERSION_COMPARE_TO , graalVMVersion ,
128+ overallCatch .marshalAsArray (int .class , overallCatch .load (24 ), overallCatch .load (2 ))));
129+ /* GraalVM >= 24.2 */
130+ try (BytecodeCreator greaterEqual24_2 = graalVm24_2Test .trueBranch ()) {
121131 greaterEqual24_2 .invokeStaticMethod (REGISTER_RUNTIME_SYSTEM_PROPERTIES ,
122132 greaterEqual24_2 .load ("user.country" ),
123133 greaterEqual24_2 .load ("US" ));
0 commit comments