You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by re...@apache.org on 2009/04/17 08:37:55 UTC

svn commit: r765865 - in /harmony/enhanced/classlib/trunk: depends/files/ make/ modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ modules/nio_char/src/main/java/java/nio/charset/

Author: regisxu
Date: Fri Apr 17 06:37:53 2009
New Revision: 765865

URL: http://svn.apache.org/viewvc?rev=765865&view=rev
Log:
Apply patches for HARMONY-6096: [classlib][icu] upgrade icu4j 3.8 to icu4j 4.0

include patches config_icu40.diff, CurrencyTest_v2.diff and Charset_v3.diff (with minor changes)

Modified:
    harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
    harmony/enhanced/classlib/trunk/make/build-java.xml
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
    harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java

Modified: harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties?rev=765865&r1=765864&r2=765865&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties (original)
+++ harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties Fri Apr 17 06:37:53 2009
@@ -165,8 +165,8 @@
 
 # ICU functionality for text/characters are provided by the ICU4J 
 # and ICU4J-charsets JAR files.
-bootclasspath.31=icu4j_3.8/icu4j-3_8.jar
-bootclasspath.32=icu4j_3.8/icu4j-charsets-3_8.jar
+bootclasspath.31=icu4j_4.0/icu4j-4_0.jar
+bootclasspath.32=icu4j_4.0/icu4j-charsets-4_0.jar
 
 # The following JARs are from Xerces/Xalan
 bootclasspath.34=xalan-j_2.7.0/xalan.jar

Modified: harmony/enhanced/classlib/trunk/make/build-java.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/build-java.xml?rev=765865&r1=765864&r2=765865&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/make/build-java.xml (original)
+++ harmony/enhanced/classlib/trunk/make/build-java.xml Fri Apr 17 06:37:53 2009
@@ -203,7 +203,7 @@
             <fileset dir="${depends.jars}">
                 <patternset includes="bcel-5.2/*.jar" />
                 <patternset includes="asm-3.1/*.jar" />
-                <patternset includes="icu4j_3.8/*.jar" />
+                <patternset includes="icu4j_4.0/*.jar" />
                 <patternset includes="mx4j_3.0.2/*.jar" />
                 <patternset includes="xalan-j_2.7.0/*.jar" />
                 <patternset includes="xerces_2.9.1/*.jar" />

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java?rev=765865&r1=765864&r2=765865&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java Fri Apr 17 06:37:53 2009
@@ -102,11 +102,11 @@
         loc = new Locale("", "ZAR");
         Currency.getInstance(loc);
 
-        loc = new Locale("", "FX");
-        Currency.getInstance(loc);
+        // loc = new Locale("", "FX");
+        // Currency.getInstance(loc);
 
-        loc = new Locale("", "FXX");
-        Currency.getInstance(loc);
+        // loc = new Locale("", "FXX");
+        // Currency.getInstance(loc);
     }
 
     /**
@@ -119,15 +119,15 @@
         Currency currUS = Currency.getInstance("USD");
 
         Locale.setDefault(Locale.US);
-        assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
+        assertEquals("currK.getSymbol()", "\u20a9", currK.getSymbol());
         // Some non-bug differences below because of CLDR data.
-        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
+        assertEquals("currI.getSymbol()", "\u20a8", currI
                 .getSymbol());
         assertEquals("currUS.getSymbol()", "$", currUS.getSymbol());
 
         Locale.setDefault(new Locale("ko", "KR"));
         assertEquals("currK.getSymbol()", "\uffe6", currK.getSymbol());
-        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
+        assertEquals("currI.getSymbol()", "0\u2264Rs.|1\u2264Re.|1<Rs.", currI
                 .getSymbol());
         assertEquals("currUS.getSymbol()", "US$", currUS.getSymbol());
 
@@ -189,10 +189,10 @@
         assertEquals("CAD", currCA.getSymbol(Locale.JAPANESE));
         assertEquals("$Ca", currCA.getSymbol(Locale.FRANCE));
         assertEquals("CAD", currCA.getSymbol(Locale.FRENCH));
-        assertEquals("Can$", currCA.getSymbol(Locale.US));
+        assertEquals("CA$", currCA.getSymbol(Locale.US));
         assertEquals("CAD", currCA.getSymbol(Locale.ENGLISH));
         assertEquals("Can$", currCA.getSymbol(new Locale("es", "US")));
-        assertEquals("Can$", currCA.getSymbol(new Locale("en", "US")));
+        assertEquals("CA$", currCA.getSymbol(new Locale("en", "US")));
 
         assertEquals("$", currCA.getSymbol(Locale.CANADA));
         assertEquals("$", currCA.getSymbol(Locale.CANADA_FRENCH));

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java?rev=765865&r1=765864&r2=765865&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java Fri Apr 17 06:37:53 2009
@@ -109,6 +109,8 @@
     // cached Charset table
     private final static HashMap<String, Charset> cachedCharsetTable = new HashMap<String, Charset>();
 
+    private static boolean inForNameInternal = false;
+
     static {
         /*
          * Create built-in charset provider even if no privilege to access
@@ -322,6 +324,11 @@
      */
     @SuppressWarnings("unchecked")
     public static SortedMap<String, Charset> availableCharsets() {
+        // workaround: conflicted Charsets with icu4j 4.0
+        Charset.forName("TIS-620");
+        Charset.forName("windows-1258");
+        Charset.forName("cp856");
+        Charset.forName("cp922");
         // Initialize the built-in charsets map cache if necessary
         if (null == _builtInCharsets) {
             synchronized (Charset.class) {
@@ -468,8 +475,10 @@
 
             // examine each configuration file
             while (e.hasMoreElements()) {
-                cs = searchConfiguredCharsets(charsetName, contextClassLoader,
+			     inForNameInternal = true;
+			     cs = searchConfiguredCharsets(charsetName, contextClassLoader,
                         e.nextElement());
+				 inForNameInternal = false;
                 if (null != cs) {
                     cacheCharset(cs);
                     return cs;
@@ -477,6 +486,8 @@
             }
         } catch (IOException ex) {
             // Unexpected ClassLoader exception, ignore
+		} finally {
+		    inForNameInternal = false;
         }
         return null;
     }
@@ -485,13 +496,17 @@
      * save charset into cachedCharsetTable
      */
     private static void cacheCharset(Charset cs) {
-        cachedCharsetTable.put(cs.name(), cs);
+        if (!cachedCharsetTable.containsKey(cs.name())){
+            cachedCharsetTable.put(cs.name(), cs);  
+        }
         Set<String> aliasesSet = cs.aliases();
         if (null != aliasesSet) {
             Iterator<String> iter = aliasesSet.iterator();
             while (iter.hasNext()) {
                 String alias = iter.next();
-                cachedCharsetTable.put(alias, cs);
+                if (!cachedCharsetTable.containsKey(alias)) {
+                    cachedCharsetTable.put(alias, cs); 
+                }
             }
         }
     }
@@ -525,8 +540,32 @@
      *             If the specified charset name is illegal.
      */
     public static boolean isSupported(String charsetName) {
-        Charset cs = forNameInternal(charsetName);
-        return (null != cs);
+        if (inForNameInternal  == true) {
+            Charset cs = cachedCharsetTable.get(charsetName);
+            if (null != cs) {
+                return true;
+            }
+
+            if (null == charsetName) {
+                throw new IllegalArgumentException();
+            }
+            checkCharsetName(charsetName);
+
+            // Try built-in charsets
+            if (_builtInProvider == null) {
+                _builtInProvider = new CharsetProviderImpl();
+            }
+            cs = _builtInProvider.charsetForName(charsetName);
+            if (null != cs) {
+                cacheCharset(cs);
+                return true;
+            }
+            return false;
+        } else {
+            Charset cs = forNameInternal(charsetName);
+            return (null != cs);
+        }
+
     }
 
     /**



Re: svn commit: r765865 - in /harmony/enhanced/classlib/trunk: depends/files/ make/ modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ modules/nio_char/src/main/java/java/nio/charset/

Posted by Nathan Beyer <nb...@gmail.com>.
On Sun, Apr 19, 2009 at 10:39 PM, Regis <xu...@gmail.com> wrote:
> Since every time icu update, it behaviors change, and we may need to modify
> our delegate code to make Harmony work with it correctly, some test cases
> need to update as well.

Is it really that bad? I can understand the upgrade from 3.8 to 4.0
would be disruptive.

In any case, it seems like we should try to keep up if there's this much pain.

>
> Deven's patch based on icu 4.0, so our test/fix work all based on this. From
> icu's release notes, seems no much update from 4.0 to 4.0.1, I suppose
> upgrade should not be hard.
>
> Nathan Beyer wrote:
>>
>> Any reason not to use 4.0.1 instead? Can we upgrade to that quickly?
>>
>> On Sun, Apr 19, 2009 at 9:45 PM, Regis <xu...@gmail.com> wrote:
>>>
>>> As title, it's icu 4.0. Thanks.
>>>
>>> Nathan Beyer wrote:
>>>>
>>>> Is this icu 4.0 or 4.0.1?
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On Apr 17, 2009, at 1:37 AM, regisxu@apache.org wrote:
>>>>
>>>>> Author: regisxu
>>>>> Date: Fri Apr 17 06:37:53 2009
>>>>> New Revision: 765865
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=765865&view=rev
>>>>> Log:
>>>>> Apply patches for HARMONY-6096: [classlib][icu] upgrade icu4j 3.8 to
>>>>> icu4j 4.0
>>>>>
>>>>> include patches config_icu40.diff, CurrencyTest_v2.diff and
>>>>> Charset_v3.diff (with minor changes)
>>>>>
>>>>> Modified:
>>>>>  harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>>>>  harmony/enhanced/classlib/trunk/make/build-java.xml
>>>>>
>>>>>
>>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>>>>
>>>>>
>>>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>>>>
>>>>> Modified:
>>>>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties?rev=765865&r1=765864&r2=765865&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> ---
>>>>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>>>> (original)
>>>>> +++
>>>>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>>>> Fri
>>>>> Apr 17 06:37:53 2009
>>>>> @@ -165,8 +165,8 @@
>>>>>
>>>>> # ICU functionality for text/characters are provided by the ICU4J
>>>>> # and ICU4J-charsets JAR files.
>>>>> -bootclasspath.31=icu4j_3.8/icu4j-3_8.jar
>>>>> -bootclasspath.32=icu4j_3.8/icu4j-charsets-3_8.jar
>>>>> +bootclasspath.31=icu4j_4.0/icu4j-4_0.jar
>>>>> +bootclasspath.32=icu4j_4.0/icu4j-charsets-4_0.jar
>>>>>
>>>>> # The following JARs are from Xerces/Xalan
>>>>> bootclasspath.34=xalan-j_2.7.0/xalan.jar
>>>>>
>>>>> Modified: harmony/enhanced/classlib/trunk/make/build-java.xml
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/build-java.xml?rev=765865&r1=765864&r2=765865&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- harmony/enhanced/classlib/trunk/make/build-java.xml (original)
>>>>> +++ harmony/enhanced/classlib/trunk/make/build-java.xml Fri Apr 17
>>>>> 06:37:53 2009
>>>>> @@ -203,7 +203,7 @@
>>>>>           <fileset dir="${depends.jars}">
>>>>>               <patternset includes="bcel-5.2/*.jar" />
>>>>>               <patternset includes="asm-3.1/*.jar" />
>>>>> -                <patternset includes="icu4j_3.8/*.jar" />
>>>>> +                <patternset includes="icu4j_4.0/*.jar" />
>>>>>               <patternset includes="mx4j_3.0.2/*.jar" />
>>>>>               <patternset includes="xalan-j_2.7.0/*.jar" />
>>>>>               <patternset includes="xerces_2.9.1/*.jar" />
>>>>>
>>>>> Modified:
>>>>>
>>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java?rev=765865&r1=765864&r2=765865&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> ---
>>>>>
>>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>>>> Fri Apr 17 06:37:53 2009
>>>>> @@ -102,11 +102,11 @@
>>>>>       loc = new Locale("", "ZAR");
>>>>>       Currency.getInstance(loc);
>>>>>
>>>>> -        loc = new Locale("", "FX");
>>>>> -        Currency.getInstance(loc);
>>>>> +        // loc = new Locale("", "FX");
>>>>> +        // Currency.getInstance(loc);
>>>>>
>>>>> -        loc = new Locale("", "FXX");
>>>>> -        Currency.getInstance(loc);
>>>>> +        // loc = new Locale("", "FXX");
>>>>> +        // Currency.getInstance(loc);
>>>>>   }
>>>>>
>>>>>   /**
>>>>> @@ -119,15 +119,15 @@
>>>>>       Currency currUS = Currency.getInstance("USD");
>>>>>
>>>>>       Locale.setDefault(Locale.US);
>>>>> -        assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
>>>>> +        assertEquals("currK.getSymbol()", "\u20a9",
>>>>> currK.getSymbol());
>>>>>       // Some non-bug differences below because of CLDR data.
>>>>> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
>>>>> +        assertEquals("currI.getSymbol()", "\u20a8", currI
>>>>>               .getSymbol());
>>>>>       assertEquals("currUS.getSymbol()", "$", currUS.getSymbol());
>>>>>
>>>>>       Locale.setDefault(new Locale("ko", "KR"));
>>>>>       assertEquals("currK.getSymbol()", "\uffe6", currK.getSymbol());
>>>>> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
>>>>> +        assertEquals("currI.getSymbol()",
>>>>> "0\u2264Rs.|1\u2264Re.|1<Rs.",
>>>>> currI
>>>>>               .getSymbol());
>>>>>       assertEquals("currUS.getSymbol()", "US$", currUS.getSymbol());
>>>>>
>>>>> @@ -189,10 +189,10 @@
>>>>>       assertEquals("CAD", currCA.getSymbol(Locale.JAPANESE));
>>>>>       assertEquals("$Ca", currCA.getSymbol(Locale.FRANCE));
>>>>>       assertEquals("CAD", currCA.getSymbol(Locale.FRENCH));
>>>>> -        assertEquals("Can$", currCA.getSymbol(Locale.US));
>>>>> +        assertEquals("CA$", currCA.getSymbol(Locale.US));
>>>>>       assertEquals("CAD", currCA.getSymbol(Locale.ENGLISH));
>>>>>       assertEquals("Can$", currCA.getSymbol(new Locale("es", "US")));
>>>>> -        assertEquals("Can$", currCA.getSymbol(new Locale("en",
>>>>> "US")));
>>>>> +        assertEquals("CA$", currCA.getSymbol(new Locale("en", "US")));
>>>>>
>>>>>       assertEquals("$", currCA.getSymbol(Locale.CANADA));
>>>>>       assertEquals("$", currCA.getSymbol(Locale.CANADA_FRENCH));
>>>>>
>>>>> Modified:
>>>>>
>>>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java?rev=765865&r1=765864&r2=765865&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> ---
>>>>>
>>>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>>>> Fri Apr 17 06:37:53 2009
>>>>> @@ -109,6 +109,8 @@
>>>>>   // cached Charset table
>>>>>   private final static HashMap<String, Charset> cachedCharsetTable =
>>>>> new
>>>>> HashMap<String, Charset>();
>>>>>
>>>>> +    private static boolean inForNameInternal = false;
>>>>> +
>>>>>   static {
>>>>>       /*
>>>>>        * Create built-in charset provider even if no privilege to
>>>>> access
>>>>> @@ -322,6 +324,11 @@
>>>>>    */
>>>>>   @SuppressWarnings("unchecked")
>>>>>   public static SortedMap<String, Charset> availableCharsets() {
>>>>> +        // workaround: conflicted Charsets with icu4j 4.0
>>>>> +        Charset.forName("TIS-620");
>>>>> +        Charset.forName("windows-1258");
>>>>> +        Charset.forName("cp856");
>>>>> +        Charset.forName("cp922");
>>>>>       // Initialize the built-in charsets map cache if necessary
>>>>>       if (null == _builtInCharsets) {
>>>>>           synchronized (Charset.class) {
>>>>> @@ -468,8 +475,10 @@
>>>>>
>>>>>           // examine each configuration file
>>>>>           while (e.hasMoreElements()) {
>>>>> -                cs = searchConfiguredCharsets(charsetName,
>>>>> contextClassLoader,
>>>>> +                 inForNameInternal = true;
>>>>> +                 cs = searchConfiguredCharsets(charsetName,
>>>>> contextClassLoader,
>>>>>                       e.nextElement());
>>>>> +                 inForNameInternal = false;
>>>>>               if (null != cs) {
>>>>>                   cacheCharset(cs);
>>>>>                   return cs;
>>>>> @@ -477,6 +486,8 @@
>>>>>           }
>>>>>       } catch (IOException ex) {
>>>>>           // Unexpected ClassLoader exception, ignore
>>>>> +        } finally {
>>>>> +            inForNameInternal = false;
>>>>>       }
>>>>>       return null;
>>>>>   }
>>>>> @@ -485,13 +496,17 @@
>>>>>    * save charset into cachedCharsetTable
>>>>>    */
>>>>>   private static void cacheCharset(Charset cs) {
>>>>> -        cachedCharsetTable.put(cs.name(), cs);
>>>>> +        if (!cachedCharsetTable.containsKey(cs.name())){
>>>>> +            cachedCharsetTable.put(cs.name(), cs);
>>>>> +        }
>>>>>       Set<String> aliasesSet = cs.aliases();
>>>>>       if (null != aliasesSet) {
>>>>>           Iterator<String> iter = aliasesSet.iterator();
>>>>>           while (iter.hasNext()) {
>>>>>               String alias = iter.next();
>>>>> -                cachedCharsetTable.put(alias, cs);
>>>>> +                if (!cachedCharsetTable.containsKey(alias)) {
>>>>> +                    cachedCharsetTable.put(alias, cs);
>>>>> +                }
>>>>>           }
>>>>>       }
>>>>>   }
>>>>> @@ -525,8 +540,32 @@
>>>>>    *             If the specified charset name is illegal.
>>>>>    */
>>>>>   public static boolean isSupported(String charsetName) {
>>>>> -        Charset cs = forNameInternal(charsetName);
>>>>> -        return (null != cs);
>>>>> +        if (inForNameInternal  == true) {
>>>>> +            Charset cs = cachedCharsetTable.get(charsetName);
>>>>> +            if (null != cs) {
>>>>> +                return true;
>>>>> +            }
>>>>> +
>>>>> +            if (null == charsetName) {
>>>>> +                throw new IllegalArgumentException();
>>>>> +            }
>>>>> +            checkCharsetName(charsetName);
>>>>> +
>>>>> +            // Try built-in charsets
>>>>> +            if (_builtInProvider == null) {
>>>>> +                _builtInProvider = new CharsetProviderImpl();
>>>>> +            }
>>>>> +            cs = _builtInProvider.charsetForName(charsetName);
>>>>> +            if (null != cs) {
>>>>> +                cacheCharset(cs);
>>>>> +                return true;
>>>>> +            }
>>>>> +            return false;
>>>>> +        } else {
>>>>> +            Charset cs = forNameInternal(charsetName);
>>>>> +            return (null != cs);
>>>>> +        }
>>>>> +
>>>>>   }
>>>>>
>>>>>   /**
>>>>>
>>>>>
>>>
>>> --
>>> Best Regards,
>>> Regis.
>>>
>>
>
>
> --
> Best Regards,
> Regis.
>

Re: svn commit: r765865 - in /harmony/enhanced/classlib/trunk: depends/files/ make/ modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ modules/nio_char/src/main/java/java/nio/charset/

Posted by Regis <xu...@gmail.com>.
Since every time icu update, it behaviors change, and we may need to modify our 
delegate code to make Harmony work with it correctly, some test cases need to 
update as well.

Deven's patch based on icu 4.0, so our test/fix work all based on this. From 
icu's release notes, seems no much update from 4.0 to 4.0.1, I suppose upgrade 
should not be hard.

Nathan Beyer wrote:
> Any reason not to use 4.0.1 instead? Can we upgrade to that quickly?
> 
> On Sun, Apr 19, 2009 at 9:45 PM, Regis <xu...@gmail.com> wrote:
>> As title, it's icu 4.0. Thanks.
>>
>> Nathan Beyer wrote:
>>> Is this icu 4.0 or 4.0.1?
>>>
>>> Sent from my iPhone
>>>
>>> On Apr 17, 2009, at 1:37 AM, regisxu@apache.org wrote:
>>>
>>>> Author: regisxu
>>>> Date: Fri Apr 17 06:37:53 2009
>>>> New Revision: 765865
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=765865&view=rev
>>>> Log:
>>>> Apply patches for HARMONY-6096: [classlib][icu] upgrade icu4j 3.8 to
>>>> icu4j 4.0
>>>>
>>>> include patches config_icu40.diff, CurrencyTest_v2.diff and
>>>> Charset_v3.diff (with minor changes)
>>>>
>>>> Modified:
>>>>   harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>>>   harmony/enhanced/classlib/trunk/make/build-java.xml
>>>>
>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>>>
>>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>>>
>>>> Modified:
>>>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>>> URL:
>>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties?rev=765865&r1=765864&r2=765865&view=diff
>>>>
>>>> ==============================================================================
>>>> ---
>>>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>>> (original)
>>>> +++
>>>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties Fri
>>>> Apr 17 06:37:53 2009
>>>> @@ -165,8 +165,8 @@
>>>>
>>>> # ICU functionality for text/characters are provided by the ICU4J
>>>> # and ICU4J-charsets JAR files.
>>>> -bootclasspath.31=icu4j_3.8/icu4j-3_8.jar
>>>> -bootclasspath.32=icu4j_3.8/icu4j-charsets-3_8.jar
>>>> +bootclasspath.31=icu4j_4.0/icu4j-4_0.jar
>>>> +bootclasspath.32=icu4j_4.0/icu4j-charsets-4_0.jar
>>>>
>>>> # The following JARs are from Xerces/Xalan
>>>> bootclasspath.34=xalan-j_2.7.0/xalan.jar
>>>>
>>>> Modified: harmony/enhanced/classlib/trunk/make/build-java.xml
>>>> URL:
>>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/build-java.xml?rev=765865&r1=765864&r2=765865&view=diff
>>>>
>>>> ==============================================================================
>>>> --- harmony/enhanced/classlib/trunk/make/build-java.xml (original)
>>>> +++ harmony/enhanced/classlib/trunk/make/build-java.xml Fri Apr 17
>>>> 06:37:53 2009
>>>> @@ -203,7 +203,7 @@
>>>>            <fileset dir="${depends.jars}">
>>>>                <patternset includes="bcel-5.2/*.jar" />
>>>>                <patternset includes="asm-3.1/*.jar" />
>>>> -                <patternset includes="icu4j_3.8/*.jar" />
>>>> +                <patternset includes="icu4j_4.0/*.jar" />
>>>>                <patternset includes="mx4j_3.0.2/*.jar" />
>>>>                <patternset includes="xalan-j_2.7.0/*.jar" />
>>>>                <patternset includes="xerces_2.9.1/*.jar" />
>>>>
>>>> Modified:
>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java?rev=765865&r1=765864&r2=765865&view=diff
>>>>
>>>> ==============================================================================
>>>> ---
>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>>> (original)
>>>> +++
>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>>> Fri Apr 17 06:37:53 2009
>>>> @@ -102,11 +102,11 @@
>>>>        loc = new Locale("", "ZAR");
>>>>        Currency.getInstance(loc);
>>>>
>>>> -        loc = new Locale("", "FX");
>>>> -        Currency.getInstance(loc);
>>>> +        // loc = new Locale("", "FX");
>>>> +        // Currency.getInstance(loc);
>>>>
>>>> -        loc = new Locale("", "FXX");
>>>> -        Currency.getInstance(loc);
>>>> +        // loc = new Locale("", "FXX");
>>>> +        // Currency.getInstance(loc);
>>>>    }
>>>>
>>>>    /**
>>>> @@ -119,15 +119,15 @@
>>>>        Currency currUS = Currency.getInstance("USD");
>>>>
>>>>        Locale.setDefault(Locale.US);
>>>> -        assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
>>>> +        assertEquals("currK.getSymbol()", "\u20a9", currK.getSymbol());
>>>>        // Some non-bug differences below because of CLDR data.
>>>> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
>>>> +        assertEquals("currI.getSymbol()", "\u20a8", currI
>>>>                .getSymbol());
>>>>        assertEquals("currUS.getSymbol()", "$", currUS.getSymbol());
>>>>
>>>>        Locale.setDefault(new Locale("ko", "KR"));
>>>>        assertEquals("currK.getSymbol()", "\uffe6", currK.getSymbol());
>>>> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
>>>> +        assertEquals("currI.getSymbol()", "0\u2264Rs.|1\u2264Re.|1<Rs.",
>>>> currI
>>>>                .getSymbol());
>>>>        assertEquals("currUS.getSymbol()", "US$", currUS.getSymbol());
>>>>
>>>> @@ -189,10 +189,10 @@
>>>>        assertEquals("CAD", currCA.getSymbol(Locale.JAPANESE));
>>>>        assertEquals("$Ca", currCA.getSymbol(Locale.FRANCE));
>>>>        assertEquals("CAD", currCA.getSymbol(Locale.FRENCH));
>>>> -        assertEquals("Can$", currCA.getSymbol(Locale.US));
>>>> +        assertEquals("CA$", currCA.getSymbol(Locale.US));
>>>>        assertEquals("CAD", currCA.getSymbol(Locale.ENGLISH));
>>>>        assertEquals("Can$", currCA.getSymbol(new Locale("es", "US")));
>>>> -        assertEquals("Can$", currCA.getSymbol(new Locale("en", "US")));
>>>> +        assertEquals("CA$", currCA.getSymbol(new Locale("en", "US")));
>>>>
>>>>        assertEquals("$", currCA.getSymbol(Locale.CANADA));
>>>>        assertEquals("$", currCA.getSymbol(Locale.CANADA_FRENCH));
>>>>
>>>> Modified:
>>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java?rev=765865&r1=765864&r2=765865&view=diff
>>>>
>>>> ==============================================================================
>>>> ---
>>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>>> (original)
>>>> +++
>>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>>> Fri Apr 17 06:37:53 2009
>>>> @@ -109,6 +109,8 @@
>>>>    // cached Charset table
>>>>    private final static HashMap<String, Charset> cachedCharsetTable = new
>>>> HashMap<String, Charset>();
>>>>
>>>> +    private static boolean inForNameInternal = false;
>>>> +
>>>>    static {
>>>>        /*
>>>>         * Create built-in charset provider even if no privilege to access
>>>> @@ -322,6 +324,11 @@
>>>>     */
>>>>    @SuppressWarnings("unchecked")
>>>>    public static SortedMap<String, Charset> availableCharsets() {
>>>> +        // workaround: conflicted Charsets with icu4j 4.0
>>>> +        Charset.forName("TIS-620");
>>>> +        Charset.forName("windows-1258");
>>>> +        Charset.forName("cp856");
>>>> +        Charset.forName("cp922");
>>>>        // Initialize the built-in charsets map cache if necessary
>>>>        if (null == _builtInCharsets) {
>>>>            synchronized (Charset.class) {
>>>> @@ -468,8 +475,10 @@
>>>>
>>>>            // examine each configuration file
>>>>            while (e.hasMoreElements()) {
>>>> -                cs = searchConfiguredCharsets(charsetName,
>>>> contextClassLoader,
>>>> +                 inForNameInternal = true;
>>>> +                 cs = searchConfiguredCharsets(charsetName,
>>>> contextClassLoader,
>>>>                        e.nextElement());
>>>> +                 inForNameInternal = false;
>>>>                if (null != cs) {
>>>>                    cacheCharset(cs);
>>>>                    return cs;
>>>> @@ -477,6 +486,8 @@
>>>>            }
>>>>        } catch (IOException ex) {
>>>>            // Unexpected ClassLoader exception, ignore
>>>> +        } finally {
>>>> +            inForNameInternal = false;
>>>>        }
>>>>        return null;
>>>>    }
>>>> @@ -485,13 +496,17 @@
>>>>     * save charset into cachedCharsetTable
>>>>     */
>>>>    private static void cacheCharset(Charset cs) {
>>>> -        cachedCharsetTable.put(cs.name(), cs);
>>>> +        if (!cachedCharsetTable.containsKey(cs.name())){
>>>> +            cachedCharsetTable.put(cs.name(), cs);
>>>> +        }
>>>>        Set<String> aliasesSet = cs.aliases();
>>>>        if (null != aliasesSet) {
>>>>            Iterator<String> iter = aliasesSet.iterator();
>>>>            while (iter.hasNext()) {
>>>>                String alias = iter.next();
>>>> -                cachedCharsetTable.put(alias, cs);
>>>> +                if (!cachedCharsetTable.containsKey(alias)) {
>>>> +                    cachedCharsetTable.put(alias, cs);
>>>> +                }
>>>>            }
>>>>        }
>>>>    }
>>>> @@ -525,8 +540,32 @@
>>>>     *             If the specified charset name is illegal.
>>>>     */
>>>>    public static boolean isSupported(String charsetName) {
>>>> -        Charset cs = forNameInternal(charsetName);
>>>> -        return (null != cs);
>>>> +        if (inForNameInternal  == true) {
>>>> +            Charset cs = cachedCharsetTable.get(charsetName);
>>>> +            if (null != cs) {
>>>> +                return true;
>>>> +            }
>>>> +
>>>> +            if (null == charsetName) {
>>>> +                throw new IllegalArgumentException();
>>>> +            }
>>>> +            checkCharsetName(charsetName);
>>>> +
>>>> +            // Try built-in charsets
>>>> +            if (_builtInProvider == null) {
>>>> +                _builtInProvider = new CharsetProviderImpl();
>>>> +            }
>>>> +            cs = _builtInProvider.charsetForName(charsetName);
>>>> +            if (null != cs) {
>>>> +                cacheCharset(cs);
>>>> +                return true;
>>>> +            }
>>>> +            return false;
>>>> +        } else {
>>>> +            Charset cs = forNameInternal(charsetName);
>>>> +            return (null != cs);
>>>> +        }
>>>> +
>>>>    }
>>>>
>>>>    /**
>>>>
>>>>
>>
>> --
>> Best Regards,
>> Regis.
>>
> 


-- 
Best Regards,
Regis.

Re: svn commit: r765865 - in /harmony/enhanced/classlib/trunk: depends/files/ make/ modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ modules/nio_char/src/main/java/java/nio/charset/

Posted by Nathan Beyer <nd...@apache.org>.
Any reason not to use 4.0.1 instead? Can we upgrade to that quickly?

On Sun, Apr 19, 2009 at 9:45 PM, Regis <xu...@gmail.com> wrote:
> As title, it's icu 4.0. Thanks.
>
> Nathan Beyer wrote:
>>
>> Is this icu 4.0 or 4.0.1?
>>
>> Sent from my iPhone
>>
>> On Apr 17, 2009, at 1:37 AM, regisxu@apache.org wrote:
>>
>>> Author: regisxu
>>> Date: Fri Apr 17 06:37:53 2009
>>> New Revision: 765865
>>>
>>> URL: http://svn.apache.org/viewvc?rev=765865&view=rev
>>> Log:
>>> Apply patches for HARMONY-6096: [classlib][icu] upgrade icu4j 3.8 to
>>> icu4j 4.0
>>>
>>> include patches config_icu40.diff, CurrencyTest_v2.diff and
>>> Charset_v3.diff (with minor changes)
>>>
>>> Modified:
>>>   harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>>   harmony/enhanced/classlib/trunk/make/build-java.xml
>>>
>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>>
>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>>
>>> Modified:
>>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>> URL:
>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties?rev=765865&r1=765864&r2=765865&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>> (original)
>>> +++
>>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties Fri
>>> Apr 17 06:37:53 2009
>>> @@ -165,8 +165,8 @@
>>>
>>> # ICU functionality for text/characters are provided by the ICU4J
>>> # and ICU4J-charsets JAR files.
>>> -bootclasspath.31=icu4j_3.8/icu4j-3_8.jar
>>> -bootclasspath.32=icu4j_3.8/icu4j-charsets-3_8.jar
>>> +bootclasspath.31=icu4j_4.0/icu4j-4_0.jar
>>> +bootclasspath.32=icu4j_4.0/icu4j-charsets-4_0.jar
>>>
>>> # The following JARs are from Xerces/Xalan
>>> bootclasspath.34=xalan-j_2.7.0/xalan.jar
>>>
>>> Modified: harmony/enhanced/classlib/trunk/make/build-java.xml
>>> URL:
>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/build-java.xml?rev=765865&r1=765864&r2=765865&view=diff
>>>
>>> ==============================================================================
>>> --- harmony/enhanced/classlib/trunk/make/build-java.xml (original)
>>> +++ harmony/enhanced/classlib/trunk/make/build-java.xml Fri Apr 17
>>> 06:37:53 2009
>>> @@ -203,7 +203,7 @@
>>>            <fileset dir="${depends.jars}">
>>>                <patternset includes="bcel-5.2/*.jar" />
>>>                <patternset includes="asm-3.1/*.jar" />
>>> -                <patternset includes="icu4j_3.8/*.jar" />
>>> +                <patternset includes="icu4j_4.0/*.jar" />
>>>                <patternset includes="mx4j_3.0.2/*.jar" />
>>>                <patternset includes="xalan-j_2.7.0/*.jar" />
>>>                <patternset includes="xerces_2.9.1/*.jar" />
>>>
>>> Modified:
>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>> URL:
>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java?rev=765865&r1=765864&r2=765865&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>> (original)
>>> +++
>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>>> Fri Apr 17 06:37:53 2009
>>> @@ -102,11 +102,11 @@
>>>        loc = new Locale("", "ZAR");
>>>        Currency.getInstance(loc);
>>>
>>> -        loc = new Locale("", "FX");
>>> -        Currency.getInstance(loc);
>>> +        // loc = new Locale("", "FX");
>>> +        // Currency.getInstance(loc);
>>>
>>> -        loc = new Locale("", "FXX");
>>> -        Currency.getInstance(loc);
>>> +        // loc = new Locale("", "FXX");
>>> +        // Currency.getInstance(loc);
>>>    }
>>>
>>>    /**
>>> @@ -119,15 +119,15 @@
>>>        Currency currUS = Currency.getInstance("USD");
>>>
>>>        Locale.setDefault(Locale.US);
>>> -        assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
>>> +        assertEquals("currK.getSymbol()", "\u20a9", currK.getSymbol());
>>>        // Some non-bug differences below because of CLDR data.
>>> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
>>> +        assertEquals("currI.getSymbol()", "\u20a8", currI
>>>                .getSymbol());
>>>        assertEquals("currUS.getSymbol()", "$", currUS.getSymbol());
>>>
>>>        Locale.setDefault(new Locale("ko", "KR"));
>>>        assertEquals("currK.getSymbol()", "\uffe6", currK.getSymbol());
>>> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
>>> +        assertEquals("currI.getSymbol()", "0\u2264Rs.|1\u2264Re.|1<Rs.",
>>> currI
>>>                .getSymbol());
>>>        assertEquals("currUS.getSymbol()", "US$", currUS.getSymbol());
>>>
>>> @@ -189,10 +189,10 @@
>>>        assertEquals("CAD", currCA.getSymbol(Locale.JAPANESE));
>>>        assertEquals("$Ca", currCA.getSymbol(Locale.FRANCE));
>>>        assertEquals("CAD", currCA.getSymbol(Locale.FRENCH));
>>> -        assertEquals("Can$", currCA.getSymbol(Locale.US));
>>> +        assertEquals("CA$", currCA.getSymbol(Locale.US));
>>>        assertEquals("CAD", currCA.getSymbol(Locale.ENGLISH));
>>>        assertEquals("Can$", currCA.getSymbol(new Locale("es", "US")));
>>> -        assertEquals("Can$", currCA.getSymbol(new Locale("en", "US")));
>>> +        assertEquals("CA$", currCA.getSymbol(new Locale("en", "US")));
>>>
>>>        assertEquals("$", currCA.getSymbol(Locale.CANADA));
>>>        assertEquals("$", currCA.getSymbol(Locale.CANADA_FRENCH));
>>>
>>> Modified:
>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>> URL:
>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java?rev=765865&r1=765864&r2=765865&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>> (original)
>>> +++
>>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
>>> Fri Apr 17 06:37:53 2009
>>> @@ -109,6 +109,8 @@
>>>    // cached Charset table
>>>    private final static HashMap<String, Charset> cachedCharsetTable = new
>>> HashMap<String, Charset>();
>>>
>>> +    private static boolean inForNameInternal = false;
>>> +
>>>    static {
>>>        /*
>>>         * Create built-in charset provider even if no privilege to access
>>> @@ -322,6 +324,11 @@
>>>     */
>>>    @SuppressWarnings("unchecked")
>>>    public static SortedMap<String, Charset> availableCharsets() {
>>> +        // workaround: conflicted Charsets with icu4j 4.0
>>> +        Charset.forName("TIS-620");
>>> +        Charset.forName("windows-1258");
>>> +        Charset.forName("cp856");
>>> +        Charset.forName("cp922");
>>>        // Initialize the built-in charsets map cache if necessary
>>>        if (null == _builtInCharsets) {
>>>            synchronized (Charset.class) {
>>> @@ -468,8 +475,10 @@
>>>
>>>            // examine each configuration file
>>>            while (e.hasMoreElements()) {
>>> -                cs = searchConfiguredCharsets(charsetName,
>>> contextClassLoader,
>>> +                 inForNameInternal = true;
>>> +                 cs = searchConfiguredCharsets(charsetName,
>>> contextClassLoader,
>>>                        e.nextElement());
>>> +                 inForNameInternal = false;
>>>                if (null != cs) {
>>>                    cacheCharset(cs);
>>>                    return cs;
>>> @@ -477,6 +486,8 @@
>>>            }
>>>        } catch (IOException ex) {
>>>            // Unexpected ClassLoader exception, ignore
>>> +        } finally {
>>> +            inForNameInternal = false;
>>>        }
>>>        return null;
>>>    }
>>> @@ -485,13 +496,17 @@
>>>     * save charset into cachedCharsetTable
>>>     */
>>>    private static void cacheCharset(Charset cs) {
>>> -        cachedCharsetTable.put(cs.name(), cs);
>>> +        if (!cachedCharsetTable.containsKey(cs.name())){
>>> +            cachedCharsetTable.put(cs.name(), cs);
>>> +        }
>>>        Set<String> aliasesSet = cs.aliases();
>>>        if (null != aliasesSet) {
>>>            Iterator<String> iter = aliasesSet.iterator();
>>>            while (iter.hasNext()) {
>>>                String alias = iter.next();
>>> -                cachedCharsetTable.put(alias, cs);
>>> +                if (!cachedCharsetTable.containsKey(alias)) {
>>> +                    cachedCharsetTable.put(alias, cs);
>>> +                }
>>>            }
>>>        }
>>>    }
>>> @@ -525,8 +540,32 @@
>>>     *             If the specified charset name is illegal.
>>>     */
>>>    public static boolean isSupported(String charsetName) {
>>> -        Charset cs = forNameInternal(charsetName);
>>> -        return (null != cs);
>>> +        if (inForNameInternal  == true) {
>>> +            Charset cs = cachedCharsetTable.get(charsetName);
>>> +            if (null != cs) {
>>> +                return true;
>>> +            }
>>> +
>>> +            if (null == charsetName) {
>>> +                throw new IllegalArgumentException();
>>> +            }
>>> +            checkCharsetName(charsetName);
>>> +
>>> +            // Try built-in charsets
>>> +            if (_builtInProvider == null) {
>>> +                _builtInProvider = new CharsetProviderImpl();
>>> +            }
>>> +            cs = _builtInProvider.charsetForName(charsetName);
>>> +            if (null != cs) {
>>> +                cacheCharset(cs);
>>> +                return true;
>>> +            }
>>> +            return false;
>>> +        } else {
>>> +            Charset cs = forNameInternal(charsetName);
>>> +            return (null != cs);
>>> +        }
>>> +
>>>    }
>>>
>>>    /**
>>>
>>>
>>
>
>
> --
> Best Regards,
> Regis.
>

Re: svn commit: r765865 - in /harmony/enhanced/classlib/trunk: depends/files/ make/ modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ modules/nio_char/src/main/java/java/nio/charset/

Posted by Regis <xu...@gmail.com>.
As title, it's icu 4.0. Thanks.

Nathan Beyer wrote:
> Is this icu 4.0 or 4.0.1?
> 
> Sent from my iPhone
> 
> On Apr 17, 2009, at 1:37 AM, regisxu@apache.org wrote:
> 
>> Author: regisxu
>> Date: Fri Apr 17 06:37:53 2009
>> New Revision: 765865
>>
>> URL: http://svn.apache.org/viewvc?rev=765865&view=rev
>> Log:
>> Apply patches for HARMONY-6096: [classlib][icu] upgrade icu4j 3.8 to 
>> icu4j 4.0
>>
>> include patches config_icu40.diff, CurrencyTest_v2.diff and 
>> Charset_v3.diff (with minor changes)
>>
>> Modified:
>>    harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>>    harmony/enhanced/classlib/trunk/make/build-java.xml
>>    
>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java 
>>
>>    
>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java 
>>
>>
>> Modified: 
>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties
>> URL: 
>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties?rev=765865&r1=765864&r2=765865&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties 
>> (original)
>> +++ 
>> harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties 
>> Fri Apr 17 06:37:53 2009
>> @@ -165,8 +165,8 @@
>>
>> # ICU functionality for text/characters are provided by the ICU4J
>> # and ICU4J-charsets JAR files.
>> -bootclasspath.31=icu4j_3.8/icu4j-3_8.jar
>> -bootclasspath.32=icu4j_3.8/icu4j-charsets-3_8.jar
>> +bootclasspath.31=icu4j_4.0/icu4j-4_0.jar
>> +bootclasspath.32=icu4j_4.0/icu4j-charsets-4_0.jar
>>
>> # The following JARs are from Xerces/Xalan
>> bootclasspath.34=xalan-j_2.7.0/xalan.jar
>>
>> Modified: harmony/enhanced/classlib/trunk/make/build-java.xml
>> URL: 
>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/build-java.xml?rev=765865&r1=765864&r2=765865&view=diff 
>>
>> ============================================================================== 
>>
>> --- harmony/enhanced/classlib/trunk/make/build-java.xml (original)
>> +++ harmony/enhanced/classlib/trunk/make/build-java.xml Fri Apr 17 
>> 06:37:53 2009
>> @@ -203,7 +203,7 @@
>>             <fileset dir="${depends.jars}">
>>                 <patternset includes="bcel-5.2/*.jar" />
>>                 <patternset includes="asm-3.1/*.jar" />
>> -                <patternset includes="icu4j_3.8/*.jar" />
>> +                <patternset includes="icu4j_4.0/*.jar" />
>>                 <patternset includes="mx4j_3.0.2/*.jar" />
>>                 <patternset includes="xalan-j_2.7.0/*.jar" />
>>                 <patternset includes="xerces_2.9.1/*.jar" />
>>
>> Modified: 
>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java?rev=765865&r1=765864&r2=765865&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java 
>> (original)
>> +++ 
>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java 
>> Fri Apr 17 06:37:53 2009
>> @@ -102,11 +102,11 @@
>>         loc = new Locale("", "ZAR");
>>         Currency.getInstance(loc);
>>
>> -        loc = new Locale("", "FX");
>> -        Currency.getInstance(loc);
>> +        // loc = new Locale("", "FX");
>> +        // Currency.getInstance(loc);
>>
>> -        loc = new Locale("", "FXX");
>> -        Currency.getInstance(loc);
>> +        // loc = new Locale("", "FXX");
>> +        // Currency.getInstance(loc);
>>     }
>>
>>     /**
>> @@ -119,15 +119,15 @@
>>         Currency currUS = Currency.getInstance("USD");
>>
>>         Locale.setDefault(Locale.US);
>> -        assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
>> +        assertEquals("currK.getSymbol()", "\u20a9", currK.getSymbol());
>>         // Some non-bug differences below because of CLDR data.
>> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
>> +        assertEquals("currI.getSymbol()", "\u20a8", currI
>>                 .getSymbol());
>>         assertEquals("currUS.getSymbol()", "$", currUS.getSymbol());
>>
>>         Locale.setDefault(new Locale("ko", "KR"));
>>         assertEquals("currK.getSymbol()", "\uffe6", currK.getSymbol());
>> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
>> +        assertEquals("currI.getSymbol()", 
>> "0\u2264Rs.|1\u2264Re.|1<Rs.", currI
>>                 .getSymbol());
>>         assertEquals("currUS.getSymbol()", "US$", currUS.getSymbol());
>>
>> @@ -189,10 +189,10 @@
>>         assertEquals("CAD", currCA.getSymbol(Locale.JAPANESE));
>>         assertEquals("$Ca", currCA.getSymbol(Locale.FRANCE));
>>         assertEquals("CAD", currCA.getSymbol(Locale.FRENCH));
>> -        assertEquals("Can$", currCA.getSymbol(Locale.US));
>> +        assertEquals("CA$", currCA.getSymbol(Locale.US));
>>         assertEquals("CAD", currCA.getSymbol(Locale.ENGLISH));
>>         assertEquals("Can$", currCA.getSymbol(new Locale("es", "US")));
>> -        assertEquals("Can$", currCA.getSymbol(new Locale("en", "US")));
>> +        assertEquals("CA$", currCA.getSymbol(new Locale("en", "US")));
>>
>>         assertEquals("$", currCA.getSymbol(Locale.CANADA));
>>         assertEquals("$", currCA.getSymbol(Locale.CANADA_FRENCH));
>>
>> Modified: 
>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java?rev=765865&r1=765864&r2=765865&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java 
>> (original)
>> +++ 
>> harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java 
>> Fri Apr 17 06:37:53 2009
>> @@ -109,6 +109,8 @@
>>     // cached Charset table
>>     private final static HashMap<String, Charset> cachedCharsetTable = 
>> new HashMap<String, Charset>();
>>
>> +    private static boolean inForNameInternal = false;
>> +
>>     static {
>>         /*
>>          * Create built-in charset provider even if no privilege to 
>> access
>> @@ -322,6 +324,11 @@
>>      */
>>     @SuppressWarnings("unchecked")
>>     public static SortedMap<String, Charset> availableCharsets() {
>> +        // workaround: conflicted Charsets with icu4j 4.0
>> +        Charset.forName("TIS-620");
>> +        Charset.forName("windows-1258");
>> +        Charset.forName("cp856");
>> +        Charset.forName("cp922");
>>         // Initialize the built-in charsets map cache if necessary
>>         if (null == _builtInCharsets) {
>>             synchronized (Charset.class) {
>> @@ -468,8 +475,10 @@
>>
>>             // examine each configuration file
>>             while (e.hasMoreElements()) {
>> -                cs = searchConfiguredCharsets(charsetName, 
>> contextClassLoader,
>> +                 inForNameInternal = true;
>> +                 cs = searchConfiguredCharsets(charsetName, 
>> contextClassLoader,
>>                         e.nextElement());
>> +                 inForNameInternal = false;
>>                 if (null != cs) {
>>                     cacheCharset(cs);
>>                     return cs;
>> @@ -477,6 +486,8 @@
>>             }
>>         } catch (IOException ex) {
>>             // Unexpected ClassLoader exception, ignore
>> +        } finally {
>> +            inForNameInternal = false;
>>         }
>>         return null;
>>     }
>> @@ -485,13 +496,17 @@
>>      * save charset into cachedCharsetTable
>>      */
>>     private static void cacheCharset(Charset cs) {
>> -        cachedCharsetTable.put(cs.name(), cs);
>> +        if (!cachedCharsetTable.containsKey(cs.name())){
>> +            cachedCharsetTable.put(cs.name(), cs);
>> +        }
>>         Set<String> aliasesSet = cs.aliases();
>>         if (null != aliasesSet) {
>>             Iterator<String> iter = aliasesSet.iterator();
>>             while (iter.hasNext()) {
>>                 String alias = iter.next();
>> -                cachedCharsetTable.put(alias, cs);
>> +                if (!cachedCharsetTable.containsKey(alias)) {
>> +                    cachedCharsetTable.put(alias, cs);
>> +                }
>>             }
>>         }
>>     }
>> @@ -525,8 +540,32 @@
>>      *             If the specified charset name is illegal.
>>      */
>>     public static boolean isSupported(String charsetName) {
>> -        Charset cs = forNameInternal(charsetName);
>> -        return (null != cs);
>> +        if (inForNameInternal  == true) {
>> +            Charset cs = cachedCharsetTable.get(charsetName);
>> +            if (null != cs) {
>> +                return true;
>> +            }
>> +
>> +            if (null == charsetName) {
>> +                throw new IllegalArgumentException();
>> +            }
>> +            checkCharsetName(charsetName);
>> +
>> +            // Try built-in charsets
>> +            if (_builtInProvider == null) {
>> +                _builtInProvider = new CharsetProviderImpl();
>> +            }
>> +            cs = _builtInProvider.charsetForName(charsetName);
>> +            if (null != cs) {
>> +                cacheCharset(cs);
>> +                return true;
>> +            }
>> +            return false;
>> +        } else {
>> +            Charset cs = forNameInternal(charsetName);
>> +            return (null != cs);
>> +        }
>> +
>>     }
>>
>>     /**
>>
>>
> 


-- 
Best Regards,
Regis.

Re: svn commit: r765865 - in /harmony/enhanced/classlib/trunk: depends/files/ make/ modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ modules/nio_char/src/main/java/java/nio/charset/

Posted by Nathan Beyer <nb...@gmail.com>.
Is this icu 4.0 or 4.0.1?

Sent from my iPhone

On Apr 17, 2009, at 1:37 AM, regisxu@apache.org wrote:

> Author: regisxu
> Date: Fri Apr 17 06:37:53 2009
> New Revision: 765865
>
> URL: http://svn.apache.org/viewvc?rev=765865&view=rev
> Log:
> Apply patches for HARMONY-6096: [classlib][icu] upgrade icu4j 3.8 to  
> icu4j 4.0
>
> include patches config_icu40.diff, CurrencyTest_v2.diff and  
> Charset_v3.diff (with minor changes)
>
> Modified:
>    harmony/enhanced/classlib/trunk/depends/files/ 
> bootclasspath.properties
>    harmony/enhanced/classlib/trunk/make/build-java.xml
>    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/ 
> org/apache/harmony/luni/tests/java/util/CurrencyTest.java
>    harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/ 
> java/nio/charset/Charset.java
>
> Modified: harmony/enhanced/classlib/trunk/depends/files/ 
> bootclasspath.properties
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/files/bootclasspath.properties?rev=765865&r1=765864&r2=765865&view=diff
> === 
> === 
> === 
> =====================================================================
> --- harmony/enhanced/classlib/trunk/depends/files/ 
> bootclasspath.properties (original)
> +++ harmony/enhanced/classlib/trunk/depends/files/ 
> bootclasspath.properties Fri Apr 17 06:37:53 2009
> @@ -165,8 +165,8 @@
>
> # ICU functionality for text/characters are provided by the ICU4J
> # and ICU4J-charsets JAR files.
> -bootclasspath.31=icu4j_3.8/icu4j-3_8.jar
> -bootclasspath.32=icu4j_3.8/icu4j-charsets-3_8.jar
> +bootclasspath.31=icu4j_4.0/icu4j-4_0.jar
> +bootclasspath.32=icu4j_4.0/icu4j-charsets-4_0.jar
>
> # The following JARs are from Xerces/Xalan
> bootclasspath.34=xalan-j_2.7.0/xalan.jar
>
> Modified: harmony/enhanced/classlib/trunk/make/build-java.xml
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/build-java.xml?rev=765865&r1=765864&r2=765865&view=diff
> === 
> === 
> === 
> =====================================================================
> --- harmony/enhanced/classlib/trunk/make/build-java.xml (original)
> +++ harmony/enhanced/classlib/trunk/make/build-java.xml Fri Apr 17  
> 06:37:53 2009
> @@ -203,7 +203,7 @@
>             <fileset dir="${depends.jars}">
>                 <patternset includes="bcel-5.2/*.jar" />
>                 <patternset includes="asm-3.1/*.jar" />
> -                <patternset includes="icu4j_3.8/*.jar" />
> +                <patternset includes="icu4j_4.0/*.jar" />
>                 <patternset includes="mx4j_3.0.2/*.jar" />
>                 <patternset includes="xalan-j_2.7.0/*.jar" />
>                 <patternset includes="xerces_2.9.1/*.jar" />
>
> Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/ 
> common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java?rev=765865&r1=765864&r2=765865&view=diff
> === 
> === 
> === 
> =====================================================================
> --- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/ 
> org/apache/harmony/luni/tests/java/util/CurrencyTest.java (original)
> +++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/ 
> org/apache/harmony/luni/tests/java/util/CurrencyTest.java Fri Apr 17  
> 06:37:53 2009
> @@ -102,11 +102,11 @@
>         loc = new Locale("", "ZAR");
>         Currency.getInstance(loc);
>
> -        loc = new Locale("", "FX");
> -        Currency.getInstance(loc);
> +        // loc = new Locale("", "FX");
> +        // Currency.getInstance(loc);
>
> -        loc = new Locale("", "FXX");
> -        Currency.getInstance(loc);
> +        // loc = new Locale("", "FXX");
> +        // Currency.getInstance(loc);
>     }
>
>     /**
> @@ -119,15 +119,15 @@
>         Currency currUS = Currency.getInstance("USD");
>
>         Locale.setDefault(Locale.US);
> -        assertEquals("currK.getSymbol()", "KRW", currK.getSymbol());
> +        assertEquals("currK.getSymbol()", "\u20a9",  
> currK.getSymbol());
>         // Some non-bug differences below because of CLDR data.
> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
> +        assertEquals("currI.getSymbol()", "\u20a8", currI
>                 .getSymbol());
>         assertEquals("currUS.getSymbol()", "$", currUS.getSymbol());
>
>         Locale.setDefault(new Locale("ko", "KR"));
>         assertEquals("currK.getSymbol()", "\uffe6",  
> currK.getSymbol());
> -        assertEquals("currI.getSymbol()", "0#Rs.|1#Re.|1<Rs.", currI
> +        assertEquals("currI.getSymbol()", "0\u2264Rs.|1\u2264Re.| 
> 1<Rs.", currI
>                 .getSymbol());
>         assertEquals("currUS.getSymbol()", "US$", currUS.getSymbol());
>
> @@ -189,10 +189,10 @@
>         assertEquals("CAD", currCA.getSymbol(Locale.JAPANESE));
>         assertEquals("$Ca", currCA.getSymbol(Locale.FRANCE));
>         assertEquals("CAD", currCA.getSymbol(Locale.FRENCH));
> -        assertEquals("Can$", currCA.getSymbol(Locale.US));
> +        assertEquals("CA$", currCA.getSymbol(Locale.US));
>         assertEquals("CAD", currCA.getSymbol(Locale.ENGLISH));
>         assertEquals("Can$", currCA.getSymbol(new Locale("es",  
> "US")));
> -        assertEquals("Can$", currCA.getSymbol(new Locale("en",  
> "US")));
> +        assertEquals("CA$", currCA.getSymbol(new Locale("en",  
> "US")));
>
>         assertEquals("$", currCA.getSymbol(Locale.CANADA));
>         assertEquals("$", currCA.getSymbol(Locale.CANADA_FRENCH));
>
> Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/ 
> java/java/nio/charset/Charset.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java?rev=765865&r1=765864&r2=765865&view=diff
> === 
> === 
> === 
> =====================================================================
> --- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/ 
> java/nio/charset/Charset.java (original)
> +++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/ 
> java/nio/charset/Charset.java Fri Apr 17 06:37:53 2009
> @@ -109,6 +109,8 @@
>     // cached Charset table
>     private final static HashMap<String, Charset> cachedCharsetTable  
> = new HashMap<String, Charset>();
>
> +    private static boolean inForNameInternal = false;
> +
>     static {
>         /*
>          * Create built-in charset provider even if no privilege to  
> access
> @@ -322,6 +324,11 @@
>      */
>     @SuppressWarnings("unchecked")
>     public static SortedMap<String, Charset> availableCharsets() {
> +        // workaround: conflicted Charsets with icu4j 4.0
> +        Charset.forName("TIS-620");
> +        Charset.forName("windows-1258");
> +        Charset.forName("cp856");
> +        Charset.forName("cp922");
>         // Initialize the built-in charsets map cache if necessary
>         if (null == _builtInCharsets) {
>             synchronized (Charset.class) {
> @@ -468,8 +475,10 @@
>
>             // examine each configuration file
>             while (e.hasMoreElements()) {
> -                cs = searchConfiguredCharsets(charsetName,  
> contextClassLoader,
> +                 inForNameInternal = true;
> +                 cs = searchConfiguredCharsets(charsetName,  
> contextClassLoader,
>                         e.nextElement());
> +                 inForNameInternal = false;
>                 if (null != cs) {
>                     cacheCharset(cs);
>                     return cs;
> @@ -477,6 +486,8 @@
>             }
>         } catch (IOException ex) {
>             // Unexpected ClassLoader exception, ignore
> +        } finally {
> +            inForNameInternal = false;
>         }
>         return null;
>     }
> @@ -485,13 +496,17 @@
>      * save charset into cachedCharsetTable
>      */
>     private static void cacheCharset(Charset cs) {
> -        cachedCharsetTable.put(cs.name(), cs);
> +        if (!cachedCharsetTable.containsKey(cs.name())){
> +            cachedCharsetTable.put(cs.name(), cs);
> +        }
>         Set<String> aliasesSet = cs.aliases();
>         if (null != aliasesSet) {
>             Iterator<String> iter = aliasesSet.iterator();
>             while (iter.hasNext()) {
>                 String alias = iter.next();
> -                cachedCharsetTable.put(alias, cs);
> +                if (!cachedCharsetTable.containsKey(alias)) {
> +                    cachedCharsetTable.put(alias, cs);
> +                }
>             }
>         }
>     }
> @@ -525,8 +540,32 @@
>      *             If the specified charset name is illegal.
>      */
>     public static boolean isSupported(String charsetName) {
> -        Charset cs = forNameInternal(charsetName);
> -        return (null != cs);
> +        if (inForNameInternal  == true) {
> +            Charset cs = cachedCharsetTable.get(charsetName);
> +            if (null != cs) {
> +                return true;
> +            }
> +
> +            if (null == charsetName) {
> +                throw new IllegalArgumentException();
> +            }
> +            checkCharsetName(charsetName);
> +
> +            // Try built-in charsets
> +            if (_builtInProvider == null) {
> +                _builtInProvider = new CharsetProviderImpl();
> +            }
> +            cs = _builtInProvider.charsetForName(charsetName);
> +            if (null != cs) {
> +                cacheCharset(cs);
> +                return true;
> +            }
> +            return false;
> +        } else {
> +            Charset cs = forNameInternal(charsetName);
> +            return (null != cs);
> +        }
> +
>     }
>
>     /**
>
>