8153417: jshell tool: use test passed locale to retrieve ResourceBundle
authorrfield
Mon, 04 Apr 2016 20:28:05 -0700
changeset 36992 ddebebe611a1
parent 36991 7f814aac1f80
child 36993 e00f4be3a47d
8153417: jshell tool: use test passed locale to retrieve ResourceBundle Reviewed-by: jlahoda
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Mon Apr 04 12:34:42 2016 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Mon Apr 04 20:28:05 2016 -0700
@@ -118,9 +118,6 @@
     private static final String RB_NAME_PREFIX  = "jdk.internal.jshell.tool.resources";
     private static final String VERSION_RB_NAME = RB_NAME_PREFIX + ".version";
     private static final String L10N_RB_NAME    = RB_NAME_PREFIX + ".l10n";
-    private static ResourceBundle versionRB = null;
-    private static ResourceBundle outputRB  = null;
-
 
     final InputStream cmdin;
     final PrintStream cmdout;
@@ -162,6 +159,9 @@
         this.locale = locale;
     }
 
+    private ResourceBundle versionRB = null;
+    private ResourceBundle outputRB  = null;
+
     private IOContext input = null;
     private boolean regenerateOnDeath = true;
     private boolean live = false;
@@ -282,9 +282,9 @@
     String getResourceString(String key) {
         if (outputRB == null) {
             try {
-                outputRB = ResourceBundle.getBundle(L10N_RB_NAME);
+                outputRB = ResourceBundle.getBundle(L10N_RB_NAME, locale);
             } catch (MissingResourceException mre) {
-                error("Cannot find ResourceBundle: %s", L10N_RB_NAME);
+                error("Cannot find ResourceBundle: %s for locale: %s", L10N_RB_NAME, locale);
                 return "";
             }
         }
@@ -2082,20 +2082,20 @@
 
     /** The current version number as a string.
      */
-    static String version() {
+    String version() {
         return version("release");  // mm.nn.oo[-milestone]
     }
 
     /** The current full version number as a string.
      */
-    static String fullVersion() {
+    String fullVersion() {
         return version("full"); // mm.mm.oo[-milestone]-build
     }
 
-    private static String version(String key) {
+    private String version(String key) {
         if (versionRB == null) {
             try {
-                versionRB = ResourceBundle.getBundle(VERSION_RB_NAME);
+                versionRB = ResourceBundle.getBundle(VERSION_RB_NAME, locale);
             } catch (MissingResourceException e) {
                 return "(version info not available)";
             }