langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Messages.java
changeset 41863 98b049c8b848
parent 40596 43b19b36e8e6
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Messages.java	Tue Nov 01 10:51:53 2016 -0400
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Messages.java	Tue Nov 01 11:28:16 2016 -0700
@@ -34,6 +34,10 @@
  * Message handling class for localization.
  */
 public class Messages {
+    /** Indicates whether line separators in messages need replacement. */
+    static final boolean REPLACE_LINESEP = ! System.lineSeparator().equals("\n");
+
+    /** The resource bundle, must be non-null. */
     static final ResourceBundle bundle;
 
     static {
@@ -41,13 +45,25 @@
         try {
             bundle = ResourceBundle.getBundle("com.sun.tools.jdeprscan.resources.jdeprscan", locale);
         } catch (MissingResourceException e) {
-            throw new InternalError("Cannot find jdeps resource bundle for locale " + locale, e);
+            throw new InternalError("Cannot find jdeprscan resource bundle for locale " + locale, e);
         }
     }
 
+    /**
+     * Gets a message from the resource bundle. If necessary, translates "\n",
+     * the line break string used in the message file, to the system-specific
+     * line break string.
+     *
+     * @param key the message key
+     * @param args the message arguments
+     */
     public static String get(String key, Object... args) {
         try {
-            return MessageFormat.format(bundle.getString(key), args);
+            String msg = MessageFormat.format(bundle.getString(key), args);
+            if (REPLACE_LINESEP) {
+                msg = msg.replace("\n", System.lineSeparator());
+            }
+            return msg;
         } catch (MissingResourceException e) {
             throw new InternalError("Missing message: " + key, e);
         }