changeset 20239:3cedbfa2946b

8017248: Compiler Diacritics Issue Reviewed-by: naoto
author kizune
date Thu, 19 Sep 2013 17:05:32 +0400
parents a08610368936
children 1818352eef49
files langtools/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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);