mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8267587: Update java.util to use enhanced switch
Reviewed-by: iris
This commit is contained in:
parent
35916ed57f
commit
ab5a7ff230
15 changed files with 556 additions and 776 deletions
|
@ -1829,19 +1829,13 @@ public abstract class ResourceBundle {
|
|||
if (bundle == null && !cacheKey.callerHasProvider()) {
|
||||
for (String format : formats) {
|
||||
try {
|
||||
switch (format) {
|
||||
case "java.class":
|
||||
bundle = ResourceBundleProviderHelper
|
||||
.loadResourceBundle(callerModule, module, baseName, targetLocale);
|
||||
|
||||
break;
|
||||
case "java.properties":
|
||||
bundle = ResourceBundleProviderHelper
|
||||
.loadPropertyResourceBundle(callerModule, module, baseName, targetLocale);
|
||||
break;
|
||||
default:
|
||||
throw new InternalError("unexpected format: " + format);
|
||||
}
|
||||
bundle = switch (format) {
|
||||
case "java.class" -> ResourceBundleProviderHelper
|
||||
.loadResourceBundle(callerModule, module, baseName, targetLocale);
|
||||
case "java.properties" -> ResourceBundleProviderHelper
|
||||
.loadPropertyResourceBundle(callerModule, module, baseName, targetLocale);
|
||||
default -> throw new InternalError("unexpected format: " + format);
|
||||
};
|
||||
|
||||
if (bundle != null) {
|
||||
cacheKey.setFormat(format);
|
||||
|
@ -2916,15 +2910,8 @@ public abstract class ResourceBundle {
|
|||
// Supply script for users who want to use zh_Hans/zh_Hant
|
||||
// as bundle names (recommended for Java7+)
|
||||
switch (region) {
|
||||
case "TW":
|
||||
case "HK":
|
||||
case "MO":
|
||||
script = "Hant";
|
||||
break;
|
||||
case "CN":
|
||||
case "SG":
|
||||
script = "Hans";
|
||||
break;
|
||||
case "TW", "HK", "MO" -> script = "Hant";
|
||||
case "CN", "SG" -> script = "Hans";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2962,12 +2949,8 @@ public abstract class ResourceBundle {
|
|||
// Supply region(country) for users who still package Chinese
|
||||
// bundles using old convension.
|
||||
switch (script) {
|
||||
case "Hans":
|
||||
region = "CN";
|
||||
break;
|
||||
case "Hant":
|
||||
region = "TW";
|
||||
break;
|
||||
case "Hans" -> region = "CN";
|
||||
case "Hant" -> region = "TW";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue