8017248: Compiler Diacritics Issue
authorkizune
Thu, 19 Sep 2013 17:04:45 +0400
changeset 20179 fa41a3d5805e
parent 20178 c4e4385f1d47
child 20180 0dedfb3744f2
8017248: Compiler Diacritics Issue Reviewed-by: naoto
jdk/src/share/classes/sun/launcher/LauncherHelper.java
jdk/test/tools/launcher/8017248/ClassÁ.java
jdk/test/tools/launcher/8017248/test.sh
--- a/jdk/src/share/classes/sun/launcher/LauncherHelper.java	Wed Sep 18 15:13:10 2013 +0100
+++ b/jdk/src/share/classes/sun/launcher/LauncherHelper.java	Thu Sep 19 17:04:45 2013 +0400
@@ -51,6 +51,7 @@
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.text.Normalizer;
 import java.util.ResourceBundle;
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -493,7 +494,19 @@
         try {
             mainClass = scloader.loadClass(cn);
         } catch (NoClassDefFoundError | ClassNotFoundException cnfe) {
-            abort(cnfe, "java.launcher.cls.error1", cn);
+            if (System.getProperty("os.name", "").contains("OS X")
+                && Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
+                try {
+                    // On Mac OS X since all names with diacretic symbols are given as decomposed it
+                    // is possible that main class name comes incorrectly from the command line
+                    // and we have to re-compose it
+                    mainClass = scloader.loadClass(Normalizer.normalize(cn, Normalizer.Form.NFC));
+                } catch (NoClassDefFoundError | ClassNotFoundException cnfe1) {
+                    abort(cnfe, "java.launcher.cls.error1", cn);
+                }
+            } else {
+                abort(cnfe, "java.launcher.cls.error1", cn);
+            }
         }
         // set to mainClass
         appClass = mainClass;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/8017248/ClassÁ.java	Thu Sep 19 17:04:45 2013 +0400
@@ -0,0 +1,5 @@
+public class ClassÁ {
+    public static void main(String args[]) {
+        System.out.println("Succes!");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/8017248/test.sh	Thu Sep 19 17:04:45 2013 +0400
@@ -0,0 +1,16 @@
+#!/bin/sh
+# @test test.sh
+# @bug 8017248
+# @summary Compiler Diacritics Issue
+# @run shell test.sh
+
+OSNAME=`uname -s`
+if [ "$OSNAME" == "Darwin" ] 
+then
+  rm *.class
+  ${TESTJAVA}/bin/javac *.java
+  ${TESTJAVA}/bin/java `echo *.class | cut -d. -f1`
+else
+  echo Test is specific to Mac OS X, skipping.
+  exit 0
+fi