ICU-5801 Merged two fixes (#5926, #5928) and readme.html from trunk for ICU4J 3.8 release.

X-SVN-Rev: 22664
diff --git a/readme.html b/readme.html
index d7fb025..687a05d 100644
--- a/readme.html
+++ b/readme.html
@@ -145,6 +145,25 @@
 binaries.  The build script detects the current Java version and comments out code
 blocks including references to J2SE 5.0 only types.</p>
 <p>
+<p><b>Changes to timezone text formatting and parsing</b>
+<p>In ICU 3.8, the behavior of date formatting and parsing has changed significantly,
+perhaps requiring recoding on your part depending on your usage. The goal of making
+the change was to return more understandable results from formatting timezones, but
+a byproduct is that the result from formatting with strings z, zzzz, v or vvvv are
+no longer unique, and thus no longer roundtrips. That is, if you use a date format
+with one of these strings, producing a certain output, you can no longer parse that
+output and expect to recover the original timezone.
+<p>What you will be able to get is a related, "best fit" mapping for the name, based
+on the region associated with the current locale and the mappings found in CLDR's
+supplemental data: for example, if you format the time zone "America/Denver",
+getting "Heure des Rocheuses" in French, and then parse, the resulting time zone
+would be "America/Denver" unless the locale in use has the region "CA" (such as
+en-CA or fr-CA), in which case "America/Edmonton" would be retrieved.
+<p>If you require roundtripping, you will need to change your code to use "VVVV"
+instead. If you are working with date patterns based on a locale, then the workaround
+is to use the DateTimePatternGenerator to convert the format you get for a locale to
+using "VVVV".
+<p>
 <p><b>New features</b>
 <p>
 See the <a href="http://www.icu-project.org/download/">ICU 3.8 download page</a> about new features in this release.
diff --git a/src/com/ibm/icu/dev/test/bidi/TestCompatibility.java b/src/com/ibm/icu/dev/test/bidi/TestCompatibility.java
index 0ba8d2f..aafa39d 100644
--- a/src/com/ibm/icu/dev/test/bidi/TestCompatibility.java
+++ b/src/com/ibm/icu/dev/test/bidi/TestCompatibility.java
@@ -138,6 +138,14 @@
 
     public void testCompatibility()
     {
+        // This test case does not work well on Java 1.4/1.4.1 environment,
+        // because of insufficient Bidi implementation in these versions.
+        String javaVersion = System.getProperty("java.version");
+        if (javaVersion.startsWith("1.4.0") || javaVersion.startsWith("1.4.1")) {
+            logln("\nSkipping TestCompatibility.  The test case is known to fail on Java "
+                    + javaVersion + "\n");
+            return;
+        }
         logln("\nEntering TestCompatibility\n");
         /* check constant field values */
         int val;
diff --git a/src/com/ibm/icu/dev/test/security.policy b/src/com/ibm/icu/dev/test/security.policy
index e792b66..340a048 100644
--- a/src/com/ibm/icu/dev/test/security.policy
+++ b/src/com/ibm/icu/dev/test/security.policy
@@ -1,6 +1,6 @@
 //#
- //#*******************************************************************************
-//#* Copyright (C) 1997-2006, International Business Machines Corporation and    *
+//#*******************************************************************************
+//#* Copyright (C) 1997-2007, International Business Machines Corporation and    *
 //#* others. All Rights Reserved.                                                *
 //#*******************************************************************************
 //#* This is the ant build file for ICU4J.  See readme.html for more information.
@@ -8,24 +8,23 @@
 // policies needed to run tests
 grant // codebase "file:${user.dir}/icu4jtests.jar"
 {
-	// temporary for debugging
-        // permission java.lang.RuntimePermission "getProtectionDomain";
+    // temporary for debugging
+    // permission java.lang.RuntimePermission "getProtectionDomain";
 
-	// ibm 141 on ibm xp can't use reflection
-	permission java.lang.RuntimePermission "accessDeclaredMembers";
+    // ibm 141 on ibm xp can't use reflection
+    permission java.lang.RuntimePermission "accessDeclaredMembers";
 
-	// needed for Locale.setDefault, only used in tests and demos
-	permission java.util.PropertyPermission "user.language", "write";
+    // needed for Locale.setDefault, only used in tests and demos
+    permission java.util.PropertyPermission "user.language", "write";
 
-	// needed for TestUtils
-	permission java.util.PropertyPermission "ICUDataPath", "read";
-	permission java.util.PropertyPermission "user.dir", "read";
-    permission java.util.PropertyPermission "U_RBBIDEBUG", "read";
+    // needed for TestUtils
+    permission java.util.PropertyPermission "ICUDataPath", "read";
+    permission java.util.PropertyPermission "user.dir", "read";
     permission java.util.PropertyPermission "GENERATE_TEST_DATA", "read";
-	
+
     // time zone tests
-	permission java.util.PropertyPermission "user.timezone", "read";
-    
+    permission java.util.PropertyPermission "user.timezone", "read";
+
     //for charsets
     permission java.lang.RuntimePermission "charsetProvider", "read";
 
@@ -43,6 +42,6 @@
 //
 grant codebase "file:${user.dir}/icu4j.jar"
 {
-	permission java.io.FilePermission "${/}${user.dir}${/}icu4jtests.jar", "read";
-	permission java.io.FilePermission "${/}${user.dir}${/}icu4j-charsets.jar", "read";
+    permission java.io.FilePermission "${/}${user.dir}${/}icu4jtests.jar", "read";
+    permission java.io.FilePermission "${/}${user.dir}${/}icu4j-charsets.jar", "read";
 };
\ No newline at end of file
diff --git a/src/com/ibm/icu/impl/ICUDebug.java b/src/com/ibm/icu/impl/ICUDebug.java
index 92d3b0d..3b5fd90 100644
--- a/src/com/ibm/icu/impl/ICUDebug.java
+++ b/src/com/ibm/icu/impl/ICUDebug.java
@@ -1,6 +1,6 @@
 /**
  *******************************************************************************
- * Copyright (C) 2001-2006, International Business Machines Corporation and    *
+ * Copyright (C) 2001-2007, International Business Machines Corporation and    *
  * others. All Rights Reserved.                                                *
  *******************************************************************************
  */
@@ -86,7 +86,7 @@
         return false;
     }
 
-/*    public static String value(String arg) {
+    public static String value(String arg) {
         String result = "false";
         if (debug) {
             int index = params.indexOf(arg);
@@ -104,7 +104,7 @@
             if (help) System.out.println("\nICUDebug.value(" + arg + ") = " + result);
         }
         return result;
-    }*/
+    }
 
 /*    static public void main(String[] args) {
         // test
diff --git a/src/com/ibm/icu/text/RBBIRuleBuilder.java b/src/com/ibm/icu/text/RBBIRuleBuilder.java
index c63897b..5bacd88 100644
--- a/src/com/ibm/icu/text/RBBIRuleBuilder.java
+++ b/src/com/ibm/icu/text/RBBIRuleBuilder.java
@@ -13,6 +13,7 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import com.ibm.icu.impl.Assert;
+import com.ibm.icu.impl.ICUDebug;
 
 class RBBIRuleBuilder {
     //   This is the main class for building (compiling) break rules into the tables
@@ -132,7 +133,8 @@
     //----------------------------------------------------------------------------------------
     RBBIRuleBuilder(String rules)
     {
-        fDebugEnv       = System.getProperty("U_RBBIDEBUG");
+        fDebugEnv       = ICUDebug.enabled("rbbi") ?
+                            ICUDebug.value("rbbi") : null;
         fRules          = rules;
         fUSetNodes      = new ArrayList();
         fRuleStatusVals = new ArrayList();
diff --git a/src/com/ibm/icu/text/RuleBasedBreakIterator.java b/src/com/ibm/icu/text/RuleBasedBreakIterator.java
index d291357..134944a 100644
--- a/src/com/ibm/icu/text/RuleBasedBreakIterator.java
+++ b/src/com/ibm/icu/text/RuleBasedBreakIterator.java
@@ -15,6 +15,7 @@
 import java.io.ByteArrayOutputStream;
 
 import com.ibm.icu.impl.Assert;
+import com.ibm.icu.impl.ICUDebug;
 
 
 /**
@@ -261,7 +262,7 @@
      * This flag lets us lazily compute the value if we are ever asked for it.
      */
     private boolean             fLastStatusIndexValid;
-    
+
     /**
      * Counter for the number of characters encountered with the "dictionary"
      *   flag set.  Normal RBBI iterators don't use it, although the code
@@ -271,15 +272,19 @@
      * @deprecated This API is ICU internal only.
      */
      protected int fDictionaryCharCount;
-    
+
     /**
      * Debugging flag.  Trace operation of state machine when true.
      * @internal
      * @deprecated This API is ICU internal only.
      */
     public static boolean       fTrace;
-    
-    
+
+    /*
+     * ICU debug argument name for RBBI
+     */
+    private static final String RBBI_DEBUG_ARG = "rbbi";
+
     /**
      * Dump the contents of the state table and character classes for this break iterator.
      * For debugging only.
@@ -298,10 +303,8 @@
 
  
         if (debugInitDone == false) {
-            String debugEnv = System.getProperty("U_RBBIDEBUG");
-            if (debugEnv!=null && debugEnv.indexOf("trace")>=0) {
-                fTrace = true;
-            }
+            fTrace = ICUDebug.enabled(RBBI_DEBUG_ARG)
+                && ICUDebug.value(RBBI_DEBUG_ARG).indexOf("trace") >= 0;
             debugInitDone = true;
         }
     }
@@ -797,7 +800,8 @@
      * @internal
      * @deprecated This API is ICU internal only.
      */
-    protected static String fDebugEnv = System.getProperty("U_RBBIDEBUG");
+    protected static String fDebugEnv = ICUDebug.enabled(RBBI_DEBUG_ARG) ?
+                                        ICUDebug.value(RBBI_DEBUG_ARG) : null;
 
     
     // 32 bit Char value returned from when an iterator has run out of range.