8017248: Compiler Diacritics Issue
authorkizune
Thu, 19 Sep 2013 17:05:32 +0400
changeset 20239 3cedbfa2946b
parent 20238 a08610368936
child 20240 1818352eef49
8017248: Compiler Diacritics Issue Reviewed-by: naoto
langtools/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java
--- a/langtools/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Wed Sep 18 22:47:06 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Thu Sep 19 17:05:32 2013 +0400
@@ -40,6 +40,7 @@
 import java.nio.CharBuffer;
 import java.nio.charset.CharsetDecoder;
 import javax.tools.JavaFileObject;
+import java.text.Normalizer;
 
 /**
  * A subclass of JavaFileObject representing regular files.
@@ -57,6 +58,7 @@
     private String name;
     final File file;
     private Reference<File> absFileRef;
+    final static boolean isMacOS = System.getProperty("os.name", "").contains("OS X");
 
     public RegularFileObject(JavacFileManager fileManager, File f) {
         this(fileManager, f.getName(), f);
@@ -180,7 +182,19 @@
         if (name.equals(n)) {
             return true;
         }
-        if (name.equalsIgnoreCase(n)) {
+        if (isMacOS && Normalizer.isNormalized(name, Normalizer.Form.NFD)
+            && Normalizer.isNormalized(n, Normalizer.Form.NFC)) {
+            // On Mac OS X it is quite possible to file name and class
+            // name normalized in a different way - in that case we have to normalize file name
+            // to the Normal Form Compised (NFC)
+            String normName = Normalizer.normalize(name, Normalizer.Form.NFC);
+            if (normName.equals(n)) {
+                this.name = normName;
+                return true;
+            }
+        }
+
+            if (name.equalsIgnoreCase(n)) {
             try {
                 // allow for Windows
                 return file.getCanonicalFile().getName().equals(n);