From 2141d6915d53c08c58f48470944db2502167be29 Mon Sep 17 00:00:00 2001
From: Doug Felt
Date: Tue, 18 Apr 2006 00:37:27 +0000
Subject: [PATCH] ICU-5145 use IllegalStateException instead of InternalError
X-SVN-Rev: 19560
---
.../src/com/ibm/icu/dev/test/ModuleTest.java | 6 +-
icu4j/src/com/ibm/icu/dev/test/TestFmwk.java | 10 +-
.../icu/dev/test/format/DateFormatTest.java | 4 +-
.../dev/test/format/TestMessageFormat.java | 4 +-
.../icu/dev/test/lang/UCharacterCaseTest.java | 4 +-
.../test/shaping/ArabicShapingRegTest.java | 10 +-
.../dev/test/util/CollectionUtilities.java | 4 +-
.../ibm/icu/dev/test/util/ICUServiceTest.java | 6 +-
.../icu/dev/test/util/UnicodeProperty.java | 2 +-
.../dev/test/util/UnicodePropertySource.java | 6 +-
.../com/ibm/icu/dev/tool/docs/CheckTags.java | 7 +-
.../ibm/icu/dev/tool/docs/CodeMangler.java | 4 +-
.../ibm/icu/dev/tool/docs/ICUJDKCompare.java | 10 +-
.../com/ibm/icu/dev/tool/docs/ICUTaglet.java | 2 +-
.../com/ibm/icu/dev/tool/docs/ReportAPI.java | 2 +-
.../tool/ime/indic/IndicInputMethodImpl.java | 4 +-
.../icu/dev/tool/index/IndexGenerator.java | 4 +-
icu4j/src/com/ibm/icu/impl/Assert.java | 8 +-
.../src/com/ibm/icu/impl/ICUBinaryStream.java | 4 +-
.../ibm/icu/impl/ICUListResourceBundle.java | 2 +-
icu4j/src/com/ibm/icu/impl/ICUNotifier.java | 156 +++++-----
icu4j/src/com/ibm/icu/impl/ICURWLock.java | 276 +++++++++---------
.../ibm/icu/impl/ICUResourceBundleImpl.java | 5 +-
icu4j/src/com/ibm/icu/impl/ICUService.java | 4 +-
.../src/com/ibm/icu/impl/IntTrieBuilder.java | 6 +-
icu4j/src/com/ibm/icu/impl/PrettyPrinter.java | 6 +-
.../com/ibm/icu/impl/UPropertyAliases.java | 10 +-
icu4j/src/com/ibm/icu/impl/Utility.java | 10 +-
icu4j/src/com/ibm/icu/lang/UCharacter.java | 4 +-
icu4j/src/com/ibm/icu/lang/UScript.java | 3 +-
icu4j/src/com/ibm/icu/text/BreakIterator.java | 2 +-
.../com/ibm/icu/text/BreakTransliterator.java | 4 +-
.../com/ibm/icu/text/CollatorServiceShim.java | 4 +-
.../com/ibm/icu/text/DateFormatSymbols.java | 2 +-
icu4j/src/com/ibm/icu/text/DecimalFormat.java | 2 +-
.../ibm/icu/text/DecimalFormatSymbols.java | 2 +-
icu4j/src/com/ibm/icu/text/Normalizer.java | 18 +-
icu4j/src/com/ibm/icu/text/Punycode.java | 4 +-
.../icu/text/RBNFChinesePostProcessor.java | 4 +-
.../com/ibm/icu/text/RuleBasedCollator.java | 3 +-
.../ibm/icu/text/StringCharacterIterator.java | 4 +-
icu4j/src/com/ibm/icu/text/UnicodeSet.java | 2 +-
icu4j/src/com/ibm/icu/util/Calendar.java | 10 +-
.../com/ibm/icu/util/CompactByteArray.java | 4 +-
.../com/ibm/icu/util/CompactCharArray.java | 4 +-
.../icu/util/GlobalizationPreferences.java | 2 +-
icu4j/src/com/ibm/icu/util/TimeZone.java | 2 +-
.../src/com/ibm/icu/util/UResourceBundle.java | 2 +-
48 files changed, 332 insertions(+), 326 deletions(-)
diff --git a/icu4j/src/com/ibm/icu/dev/test/ModuleTest.java b/icu4j/src/com/ibm/icu/dev/test/ModuleTest.java
index b25ba8d690c..8708568fce1 100644
--- a/icu4j/src/com/ibm/icu/dev/test/ModuleTest.java
+++ b/icu4j/src/com/ibm/icu/dev/test/ModuleTest.java
@@ -1,6 +1,6 @@
/**
*******************************************************************************
- * Copyright (C) 2001-2004, International Business Machines Corporation and *
+ * Copyright (C) 2001-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -74,7 +74,7 @@ public class ModuleTest extends TestFmwk {
}
}
catch (Exception e) {
- throw new InternalError(e.getMessage());
+ throw new IllegalStateException(e.getMessage());
}
}
return target;
@@ -199,7 +199,7 @@ public class ModuleTest extends TestFmwk {
}
}
catch (Exception e) {
- throw new InternalError(e.getMessage());
+ throw new IllegalStateException(e.getMessage());
}
}
*/
diff --git a/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java b/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java
index 6c5af64b74d..117404a811a 100755
--- a/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java
+++ b/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java
@@ -134,7 +134,7 @@ public class TestFmwk extends AbstractTestLog {
protected TestGroup(String defaultPackage, String[] classnames,
String description) {
if (classnames == null) {
- throw new InternalError("classnames must not be null");
+ throw new IllegalStateException("classnames must not be null");
}
if (defaultPackage == null) {
@@ -241,9 +241,9 @@ public class TestFmwk extends AbstractTestLog {
subtest.params = params;
return subtest;
} catch (InstantiationException e) {
- throw new InternalError(e.getMessage());
+ throw new IllegalStateException(e.getMessage());
} catch (IllegalAccessException e) {
- throw new InternalError(e.getMessage());
+ throw new IllegalStateException(e.getMessage());
}
}
return null;
@@ -261,7 +261,7 @@ public class TestFmwk extends AbstractTestLog {
try {
Class cls = Class.forName(name);
if (!TestFmwk.class.isAssignableFrom(cls)) {
- throw new InternalError("class " + name
+ throw new IllegalStateException("class " + name
+ " does not extend TestFmwk");
}
@@ -1530,7 +1530,7 @@ public class TestFmwk extends AbstractTestLog {
Field f = testClass.getField("CLASS_TARGET_NAME");
name = (String) f.get(null);
} catch (IllegalAccessException e) {
- throw new InternalError(
+ throw new IllegalStateException(
"static field CLASS_TARGET_NAME must be accessible");
} catch (NoSuchFieldException e) {
int n = Math.max(name.lastIndexOf('.'), name.lastIndexOf('$'));
diff --git a/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java b/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java
index c34a93fbc63..e9b46c6ef1c 100755
--- a/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java
+++ b/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 2001-2005, International Business Machines Corporation and *
+ * Copyright (C) 2001-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -2154,7 +2154,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
// hmmm... this shouldn't happen. don't want to exit this
// fn with timezone improperly set, so just in case
TimeZone.setDefault(oldtz);
- throw new InternalError(e.getMessage());
+ throw new IllegalStateException(e.getMessage());
}
// create DFS that recognizes our bogus time zone, sortof
diff --git a/icu4j/src/com/ibm/icu/dev/test/format/TestMessageFormat.java b/icu4j/src/com/ibm/icu/dev/test/format/TestMessageFormat.java
index fa13c04b8a3..d72b4d8107b 100644
--- a/icu4j/src/com/ibm/icu/dev/test/format/TestMessageFormat.java
+++ b/icu4j/src/com/ibm/icu/dev/test/format/TestMessageFormat.java
@@ -1,6 +1,6 @@
/*
**********************************************************************
-* Copyright (c) 2004-2005, International Business Machines
+* Copyright (c) 2004-2006, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
@@ -815,7 +815,7 @@ public class TestMessageFormat extends com.ibm.icu.dev.test.TestFmwk {
num = numFmt.parse(values[j]);
}
catch (Exception e) {
- throw new InternalError("failed to parse test argument");
+ throw new IllegalStateException("failed to parse test argument");
}
args[0] = num;
String result = fmt.format(args);
diff --git a/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterCaseTest.java b/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterCaseTest.java
index ef96abab68b..d26f59c4730 100644
--- a/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterCaseTest.java
+++ b/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterCaseTest.java
@@ -1,6 +1,6 @@
/**
*******************************************************************************
-* Copyright (C) 1996-2005, International Business Machines Corporation and *
+* Copyright (C) 1996-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -324,8 +324,6 @@ public final class UCharacterCaseTest extends TestFmwk
}
}catch(Exception ex){
warnln("Could not find data for BreakIterators");
- }catch(InternalError e){
- warnln("Could not find data for BreakIterators");
}
}
diff --git a/icu4j/src/com/ibm/icu/dev/test/shaping/ArabicShapingRegTest.java b/icu4j/src/com/ibm/icu/dev/test/shaping/ArabicShapingRegTest.java
index fa5d1b0fc86..775c9216872 100755
--- a/icu4j/src/com/ibm/icu/dev/test/shaping/ArabicShapingRegTest.java
+++ b/icu4j/src/com/ibm/icu/dev/test/shaping/ArabicShapingRegTest.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
-* Copyright (C) 2001-2005, International Business Machines
+* Copyright (C) 2001-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@@ -348,13 +348,13 @@ public class ArabicShapingRegTest extends TestFmwk {
catch(MissingResourceException e){
throw e;
}
+ catch (IllegalStateException ie){
+ warnln("IllegalStateException: "+ie.toString());
+ return;
+ }
catch (Exception e) {
ex = e;
}
- catch (InternalError ie){
- warnln("InternalError: "+ie.toString());
- return;
- }
if (!test.result.equals(result)) {
reportTestFailure(i, test, shaper, result, ex);
diff --git a/icu4j/src/com/ibm/icu/dev/test/util/CollectionUtilities.java b/icu4j/src/com/ibm/icu/dev/test/util/CollectionUtilities.java
index 7e7eba94be2..bfa7caf3377 100644
--- a/icu4j/src/com/ibm/icu/dev/test/util/CollectionUtilities.java
+++ b/icu4j/src/com/ibm/icu/dev/test/util/CollectionUtilities.java
@@ -299,7 +299,9 @@ public final class CollectionUtilities {
result.append("]");
String sresult = result.toString();
UnicodeSet doubleCheck = new UnicodeSet(sresult);
- if (!uset.equals(doubleCheck)) throw new InternalError("Failure to round-trip in pretty-print");
+ if (!uset.equals(doubleCheck)) {
+ throw new IllegalStateException("Failure to round-trip in pretty-print");
+ }
return sresult;
}
diff --git a/icu4j/src/com/ibm/icu/dev/test/util/ICUServiceTest.java b/icu4j/src/com/ibm/icu/dev/test/util/ICUServiceTest.java
index e738f9bb8e4..aa8be30beaa 100644
--- a/icu4j/src/com/ibm/icu/dev/test/util/ICUServiceTest.java
+++ b/icu4j/src/com/ibm/icu/dev/test/util/ICUServiceTest.java
@@ -902,7 +902,7 @@ public class ICUServiceTest extends TestFmwk
rwlock.releaseRead();
errln("no error thrown");
}
- catch (InternalError e) {
+ catch (IllegalStateException e) {
logln("OK: " + e.getMessage());
}
@@ -910,7 +910,7 @@ public class ICUServiceTest extends TestFmwk
rwlock.releaseWrite();
errln("no error thrown");
}
- catch (InternalError e) {
+ catch (IllegalStateException e) {
logln("OK: " + e.getMessage());
}
@@ -961,7 +961,7 @@ public class ICUServiceTest extends TestFmwk
nf.addListener(new WrongListener());
errln("added wrong listener");
}
- catch (InternalError e) {
+ catch (IllegalStateException e) {
logln(e.getMessage());
}
catch (Exception e) {
diff --git a/icu4j/src/com/ibm/icu/dev/test/util/UnicodeProperty.java b/icu4j/src/com/ibm/icu/dev/test/util/UnicodeProperty.java
index 134e71d4de4..1595a51603c 100644
--- a/icu4j/src/com/ibm/icu/dev/test/util/UnicodeProperty.java
+++ b/icu4j/src/com/ibm/icu/dev/test/util/UnicodeProperty.java
@@ -839,7 +839,7 @@ Name: Unicode_1_Name
try {
return super.clone();
} catch (CloneNotSupportedException e) {
- throw new InternalError("Should never happen.");
+ throw new IllegalStateException("Should never happen.");
}
}
*/
diff --git a/icu4j/src/com/ibm/icu/dev/test/util/UnicodePropertySource.java b/icu4j/src/com/ibm/icu/dev/test/util/UnicodePropertySource.java
index 59141f56553..bf5b62a6369 100644
--- a/icu4j/src/com/ibm/icu/dev/test/util/UnicodePropertySource.java
+++ b/icu4j/src/com/ibm/icu/dev/test/util/UnicodePropertySource.java
@@ -1,7 +1,7 @@
/*
*******************************************************************************
- * Copyright (C) 2002-2004, International Business Machines Corporation and *
+ * Copyright (C) 2002-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -49,7 +49,7 @@ public abstract class UnicodePropertySource implements Cloneable {
result.filter = (StringFilter)filter.clone();
return result;
} catch (CloneNotSupportedException e) {
- throw new InternalError("Should never happen.");
+ throw new IllegalStateException("Should never happen.");
}
}
@@ -128,7 +128,7 @@ public abstract class UnicodePropertySource implements Cloneable {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
- throw new InternalError("Should never happen.");
+ throw new IllegalStateException("Should never happen.");
}
}
}
diff --git a/icu4j/src/com/ibm/icu/dev/tool/docs/CheckTags.java b/icu4j/src/com/ibm/icu/dev/tool/docs/CheckTags.java
index ca0820d6e53..8479fdf9ee6 100644
--- a/icu4j/src/com/ibm/icu/dev/tool/docs/CheckTags.java
+++ b/icu4j/src/com/ibm/icu/dev/tool/docs/CheckTags.java
@@ -1,6 +1,6 @@
/**
*******************************************************************************
-* Copyright (C) 2002-2005, International Business Machines Corporation and *
+* Copyright (C) 2002-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -400,6 +400,9 @@ public class CheckTags {
if (!foundRequiredTag) {
errln("missing required tag [" + doc.position() + "]");
}
+ if (foundInternalTag && !foundDeprecatedTag) {
+ errln("internal tag missing deprecated");
+ }
if (foundDraftTag && !foundDeprecatedTag) {
errln("draft tag missing deprecated");
}
@@ -410,6 +413,6 @@ public class CheckTags {
logln("stable deprecated");
}
- return !foundInternalTag && !retainAll;
+ return !retainAll;
}
}
diff --git a/icu4j/src/com/ibm/icu/dev/tool/docs/CodeMangler.java b/icu4j/src/com/ibm/icu/dev/tool/docs/CodeMangler.java
index 1d5531fdaa1..d4b260a902f 100644
--- a/icu4j/src/com/ibm/icu/dev/tool/docs/CodeMangler.java
+++ b/icu4j/src/com/ibm/icu/dev/tool/docs/CodeMangler.java
@@ -722,7 +722,7 @@ public class CodeMangler {
}
return false;
default:
- throw new InternalError();
+ throw new IllegalStateException();
}
}
if (state == 6) {
@@ -806,7 +806,7 @@ public class CodeMangler {
case 4:
keyRelVal[2] = line.substring(mark).trim(); break; // found a word, possible rel, and who knows what
default:
- throw new InternalError();
+ throw new IllegalStateException();
}
return true;
}
diff --git a/icu4j/src/com/ibm/icu/dev/tool/docs/ICUJDKCompare.java b/icu4j/src/com/ibm/icu/dev/tool/docs/ICUJDKCompare.java
index c2bec4933f4..2e10ba6071d 100644
--- a/icu4j/src/com/ibm/icu/dev/tool/docs/ICUJDKCompare.java
+++ b/icu4j/src/com/ibm/icu/dev/tool/docs/ICUJDKCompare.java
@@ -137,7 +137,7 @@ public class ICUJDKCompare {
ignorelist = args[++i];
} else {
System.err.println("unrecognized argument: " + arg);
- throw new InternalError();
+ throw new IllegalStateException();
}
}
@@ -157,7 +157,7 @@ public class ICUJDKCompare {
}
catch (Exception e) {
System.err.println(e);
- throw new InternalError();
+ throw new IllegalStateException();
}
} else { // a list of ignoreinfo separated by semicolons
ignore = ignorelist.split("\\s*;\\s*");
@@ -181,7 +181,7 @@ public class ICUJDKCompare {
}
catch (Exception e) {
System.err.println(e);
- throw new InternalError();
+ throw new IllegalStateException();
}
} else { // a list of names separated by semicolons
names = namelist.split("\\s*;\\s*");
@@ -450,7 +450,7 @@ public class ICUJDKCompare {
MorC t = mr.overrides[i];
if (t == null) {
// this shouldn't happen, as the target record should not have been modified
- throw new InternalError();
+ throw new IllegalStateException();
}
if (removeOverridden(t)) {
result = true;
@@ -701,7 +701,7 @@ public class ICUJDKCompare {
return i;
}
}
- throw new InternalError("could not find primitive class: " + cls);
+ throw new IllegalStateException("could not find primitive class: " + cls);
}
static boolean assignableFrom(Class lhs, Class rhs) {
diff --git a/icu4j/src/com/ibm/icu/dev/tool/docs/ICUTaglet.java b/icu4j/src/com/ibm/icu/dev/tool/docs/ICUTaglet.java
index 2c684dadb31..2407f200f55 100644
--- a/icu4j/src/com/ibm/icu/dev/tool/docs/ICUTaglet.java
+++ b/icu4j/src/com/ibm/icu/dev/tool/docs/ICUTaglet.java
@@ -107,7 +107,7 @@ public abstract class ICUTaglet implements Taglet {
for (int i = 0; i < tags.length; ++i) {
msg += " [" + i + "] " + tags[i] + "\n";
}
- throw new InternalError(msg);
+ throw new IllegalStateException(msg);
} else if (tags.length > 0) {
return toString(tags[0]);
}
diff --git a/icu4j/src/com/ibm/icu/dev/tool/docs/ReportAPI.java b/icu4j/src/com/ibm/icu/dev/tool/docs/ReportAPI.java
index 4c7c8bd4ea0..5c18d7a67d5 100644
--- a/icu4j/src/com/ibm/icu/dev/tool/docs/ReportAPI.java
+++ b/icu4j/src/com/ibm/icu/dev/tool/docs/ReportAPI.java
@@ -248,7 +248,7 @@ public class ReportAPI {
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(os, "UTF-8")));
}
catch (UnsupportedEncodingException e) {
- throw new InternalError(); // UTF-8 should always be supported
+ throw new IllegalStateException(); // UTF-8 should always be supported
}
DateFormat fmt = new SimpleDateFormat("yyyy");
diff --git a/icu4j/src/com/ibm/icu/dev/tool/ime/indic/IndicInputMethodImpl.java b/icu4j/src/com/ibm/icu/dev/tool/ime/indic/IndicInputMethodImpl.java
index d76f123630a..55e4f32f9f3 100644
--- a/icu4j/src/com/ibm/icu/dev/tool/ime/indic/IndicInputMethodImpl.java
+++ b/icu4j/src/com/ibm/icu/dev/tool/ime/indic/IndicInputMethodImpl.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 2000-2004, International Business Machines Corporation and *
+ * Copyright (C) 2000-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -362,7 +362,7 @@ class IndicInputMethodImpl {
ACIText clone = (ACIText) super.clone();
return clone;
} catch (CloneNotSupportedException e) {
- throw new InternalError();
+ throw new IllegalStateException();
}
}
diff --git a/icu4j/src/com/ibm/icu/dev/tool/index/IndexGenerator.java b/icu4j/src/com/ibm/icu/dev/tool/index/IndexGenerator.java
index 2bdf174ae75..f89394967a0 100644
--- a/icu4j/src/com/ibm/icu/dev/tool/index/IndexGenerator.java
+++ b/icu4j/src/com/ibm/icu/dev/tool/index/IndexGenerator.java
@@ -1,6 +1,6 @@
/**
*******************************************************************************
-* Copyright (C) 2005, International Business Machines Corporation and *
+* Copyright (C) 2005-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -74,7 +74,7 @@ public class IndexGenerator {
System.out.println("Usage: IndexGenerator inDir outDir");
System.out.println(" inDir is an existing directory whose locale-based resources are to be enumerated");
System.out.println(" outDir is an existing directory in which the res_index.txt file will be placed");
- throw new InternalError("Usage");
+ throw new IllegalStateException("Usage");
}
}
diff --git a/icu4j/src/com/ibm/icu/impl/Assert.java b/icu4j/src/com/ibm/icu/impl/Assert.java
index 2104c980571..7d8b113e6dd 100644
--- a/icu4j/src/com/ibm/icu/impl/Assert.java
+++ b/icu4j/src/com/ibm/icu/impl/Assert.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
-* Copyright (C) 2005, International Business Machines
+* Copyright (C) 2005-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@@ -12,12 +12,12 @@ public class Assert {
fail(e.toString()); // can't wrap exceptions in jdk 1.3
}
public static void fail(String msg) {
- throw new InternalError("failure '" + msg + "'");
+ throw new IllegalStateException("failure '" + msg + "'");
}
public static void assrt(boolean val) {
- if (!val) throw new InternalError("assert failed");
+ if (!val) throw new IllegalStateException("assert failed");
}
public static void assrt(String msg, boolean val) {
- if (!val) throw new InternalError("assert '" + msg + "' failed");
+ if (!val) throw new IllegalStateException("assert '" + msg + "' failed");
}
}
diff --git a/icu4j/src/com/ibm/icu/impl/ICUBinaryStream.java b/icu4j/src/com/ibm/icu/impl/ICUBinaryStream.java
index a45862ab4be..ad492515fdd 100644
--- a/icu4j/src/com/ibm/icu/impl/ICUBinaryStream.java
+++ b/icu4j/src/com/ibm/icu/impl/ICUBinaryStream.java
@@ -1,6 +1,6 @@
/*
**********************************************************************
-* Copyright (c) 2002-2005, International Business Machines
+* Copyright (c) 2002-2006, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
@@ -51,7 +51,7 @@ class ICUBinaryStream extends DataInputStream {
reset();
int actual = skipBytes(offset);
if (actual != offset) {
- throw new InternalError("Skip(" + offset + ") only skipped " +
+ throw new IllegalStateException("Skip(" + offset + ") only skipped " +
actual + " bytes");
}
if (false) System.out.println("(seek " + offset + ")");
diff --git a/icu4j/src/com/ibm/icu/impl/ICUListResourceBundle.java b/icu4j/src/com/ibm/icu/impl/ICUListResourceBundle.java
index 0dc780f2007..2da6638860d 100644
--- a/icu4j/src/com/ibm/icu/impl/ICUListResourceBundle.java
+++ b/icu4j/src/com/ibm/icu/impl/ICUListResourceBundle.java
@@ -177,7 +177,7 @@ public class ICUListResourceBundle extends ListResourceBundle {
stream.reset();
length <<= 1;
} else {
- throw new InternalError("maximum input stream length exceeded");
+ throw new IllegalStateException("maximum input stream length exceeded");
}
}
diff --git a/icu4j/src/com/ibm/icu/impl/ICUNotifier.java b/icu4j/src/com/ibm/icu/impl/ICUNotifier.java
index 8ea5b616fe7..b49b2a85435 100644
--- a/icu4j/src/com/ibm/icu/impl/ICUNotifier.java
+++ b/icu4j/src/com/ibm/icu/impl/ICUNotifier.java
@@ -1,6 +1,6 @@
/**
*******************************************************************************
- * Copyright (C) 2001-2004, International Business Machines Corporation and *
+ * Copyright (C) 2001-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -41,29 +41,29 @@ public abstract class ICUNotifier {
* silently ignored.
*/
public void addListener(EventListener l) {
- if (l == null) {
- throw new NullPointerException();
- }
+ if (l == null) {
+ throw new NullPointerException();
+ }
- if (acceptsListener(l)) {
- synchronized (notifyLock) {
- if (listeners == null) {
- listeners = new ArrayList(5);
+ if (acceptsListener(l)) {
+ synchronized (notifyLock) {
+ if (listeners == null) {
+ listeners = new ArrayList(5);
+ } else {
+ // identity equality check
+ Iterator iter = listeners.iterator();
+ while (iter.hasNext()) {
+ if (iter.next() == l) {
+ return;
+ }
+ }
+ }
+
+ listeners.add(l);
+ }
} else {
- // identity equality check
- Iterator iter = listeners.iterator();
- while (iter.hasNext()) {
- if (iter.next() == l) {
- return;
- }
- }
+ throw new IllegalStateException("Listener invalid for this notifier.");
}
-
- listeners.add(l);
- }
- } else {
- throw new InternalError("Listener invalid for this notifier.");
- }
}
/**
@@ -72,24 +72,24 @@ public abstract class ICUNotifier {
* not registered will be silently ignored.
*/
public void removeListener(EventListener l) {
- if (l == null) {
- throw new NullPointerException();
- }
- synchronized (notifyLock) {
- if (listeners != null) {
- // identity equality check
- Iterator iter = listeners.iterator();
- while (iter.hasNext()) {
- if (iter.next() == l) {
- iter.remove();
- if (listeners.size() == 0) {
- listeners = null;
- }
- return;
+ if (l == null) {
+ throw new NullPointerException();
+ }
+ synchronized (notifyLock) {
+ if (listeners != null) {
+ // identity equality check
+ Iterator iter = listeners.iterator();
+ while (iter.hasNext()) {
+ if (iter.next() == l) {
+ iter.remove();
+ if (listeners.size() == 0) {
+ listeners = null;
+ }
+ return;
+ }
+ }
}
}
- }
- }
}
/**
@@ -98,64 +98,64 @@ public abstract class ICUNotifier {
* is called on each listener from the notification thread.
*/
public void notifyChanged() {
- if (listeners != null) {
- synchronized (notifyLock) {
if (listeners != null) {
- if (notifyThread == null) {
- notifyThread = new NotifyThread(this);
- notifyThread.setDaemon(true);
- notifyThread.start();
+ synchronized (notifyLock) {
+ if (listeners != null) {
+ if (notifyThread == null) {
+ notifyThread = new NotifyThread(this);
+ notifyThread.setDaemon(true);
+ notifyThread.start();
+ }
+ notifyThread.queue(listeners.toArray());
+ }
}
- notifyThread.queue(listeners.toArray());
}
- }
- }
}
/**
* The notification thread.
*/
private static class NotifyThread extends Thread {
- private final ICUNotifier notifier;
- private final List queue = new LinkedList();
+ private final ICUNotifier notifier;
+ private final List queue = new LinkedList();
- NotifyThread(ICUNotifier notifier) {
- this.notifier = notifier;
- }
-
- /**
- * Queue the notification on the thread.
- */
- public void queue(Object[] list) {
- synchronized (this) {
- queue.add(list);
- notify();
+ NotifyThread(ICUNotifier notifier) {
+ this.notifier = notifier;
}
- }
- /**
- * Wait for a notification to be queued, then notify all
- * listeners listed in the notification.
- */
- public void run() {
- Object[] list;
- while (true) {
- try {
+ /**
+ * Queue the notification on the thread.
+ */
+ public void queue(Object[] list) {
synchronized (this) {
- while (queue.isEmpty()) {
- wait();
- }
- list = (Object[])queue.remove(0);
+ queue.add(list);
+ notify();
}
+ }
- for (int i = 0; i < list.length; ++i) {
- notifier.notifyListener((EventListener)list[i]);
+ /**
+ * Wait for a notification to be queued, then notify all
+ * listeners listed in the notification.
+ */
+ public void run() {
+ Object[] list;
+ while (true) {
+ try {
+ synchronized (this) {
+ while (queue.isEmpty()) {
+ wait();
+ }
+ list = (Object[])queue.remove(0);
+ }
+
+ for (int i = 0; i < list.length; ++i) {
+ notifier.notifyListener((EventListener)list[i]);
+ }
+ }
+ catch (InterruptedException e) {
+ }
}
}
- catch (InterruptedException e) {
- }
- }
- }
}
/**
diff --git a/icu4j/src/com/ibm/icu/impl/ICURWLock.java b/icu4j/src/com/ibm/icu/impl/ICURWLock.java
index 12f3de0e694..ec150708983 100644
--- a/icu4j/src/com/ibm/icu/impl/ICURWLock.java
+++ b/icu4j/src/com/ibm/icu/impl/ICURWLock.java
@@ -1,6 +1,6 @@
/**
*******************************************************************************
- * Copyright (C) 2001-2004, International Business Machines Corporation and *
+ * Copyright (C) 2001-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -43,141 +43,141 @@ public class ICURWLock {
* Internal class used to gather statistics on the RWLock.
*/
public final static class Stats {
- /**
- * Number of times read access granted (read count).
- */
- public int _rc;
+ /**
+ * Number of times read access granted (read count).
+ */
+ public int _rc;
- /**
- * Number of times concurrent read access granted (multiple read count).
- */
- public int _mrc;
+ /**
+ * Number of times concurrent read access granted (multiple read count).
+ */
+ public int _mrc;
- /**
- * Number of times blocked for read (waiting reader count).
- */
- public int _wrc; // wait for read
+ /**
+ * Number of times blocked for read (waiting reader count).
+ */
+ public int _wrc; // wait for read
- /**
- * Number of times write access granted (writer count).
- */
- public int _wc;
+ /**
+ * Number of times write access granted (writer count).
+ */
+ public int _wc;
- /**
- * Number of times blocked for write (waiting writer count).
- */
- public int _wwc;
+ /**
+ * Number of times blocked for write (waiting writer count).
+ */
+ public int _wwc;
- private Stats() {
- }
+ private Stats() {
+ }
- private Stats(int rc, int mrc, int wrc, int wc, int wwc) {
- this._rc = rc;
- this._mrc = mrc;
- this._wrc = wrc;
- this._wc = wc;
- this._wwc = wwc;
- }
+ private Stats(int rc, int mrc, int wrc, int wc, int wwc) {
+ this._rc = rc;
+ this._mrc = mrc;
+ this._wrc = wrc;
+ this._wc = wc;
+ this._wwc = wwc;
+ }
- private Stats(Stats rhs) {
- this(rhs._rc, rhs._mrc, rhs._wrc, rhs._wc, rhs._wwc);
- }
+ private Stats(Stats rhs) {
+ this(rhs._rc, rhs._mrc, rhs._wrc, rhs._wc, rhs._wwc);
+ }
- /**
- * Return a string listing all the stats.
- */
- public String toString() {
- return " rc: " + _rc +
- " mrc: " + _mrc +
- " wrc: " + _wrc +
- " wc: " + _wc +
- " wwc: " + _wwc;
- }
+ /**
+ * Return a string listing all the stats.
+ */
+ public String toString() {
+ return " rc: " + _rc +
+ " mrc: " + _mrc +
+ " wrc: " + _wrc +
+ " wc: " + _wc +
+ " wwc: " + _wwc;
+ }
}
/**
* Reset the stats. Returns existing stats, if any.
*/
public synchronized Stats resetStats() {
- Stats result = stats;
- stats = new Stats();
- return result;
+ Stats result = stats;
+ stats = new Stats();
+ return result;
}
/**
* Clear the stats (stop collecting stats). Returns existing stats, if any.
*/
public synchronized Stats clearStats() {
- Stats result = stats;
- stats = null;
- return result;
+ Stats result = stats;
+ stats = null;
+ return result;
}
/**
* Return a snapshot of the current stats. This does not reset the stats.
*/
public synchronized Stats getStats() {
- return stats == null ? null : new Stats(stats);
+ return stats == null ? null : new Stats(stats);
}
// utilities
private synchronized boolean gotRead() {
- ++rc;
- if (stats != null) {
- ++stats._rc;
- if (rc > 1) ++stats._mrc;
- }
- return true;
+ ++rc;
+ if (stats != null) {
+ ++stats._rc;
+ if (rc > 1) ++stats._mrc;
+ }
+ return true;
}
private synchronized boolean getRead() {
- if (rc >= 0 && wwc == 0) {
- return gotRead();
- }
- ++wrc;
- return false;
+ if (rc >= 0 && wwc == 0) {
+ return gotRead();
+ }
+ ++wrc;
+ return false;
}
private synchronized boolean retryRead() {
- if (stats != null) ++stats._wrc;
- if (rc >= 0 && wwc == 0) {
- --wrc;
- return gotRead();
- }
- return false;
+ if (stats != null) ++stats._wrc;
+ if (rc >= 0 && wwc == 0) {
+ --wrc;
+ return gotRead();
+ }
+ return false;
}
private synchronized boolean finishRead() {
- if (rc > 0) {
- return (0 == --rc && wwc > 0);
- }
- throw new InternalError("no current reader to release");
+ if (rc > 0) {
+ return (0 == --rc && wwc > 0);
+ }
+ throw new IllegalStateException("no current reader to release");
}
private synchronized boolean gotWrite() {
- rc = -1;
- if (stats != null) {
- ++stats._wc;
- }
- return true;
+ rc = -1;
+ if (stats != null) {
+ ++stats._wc;
+ }
+ return true;
}
private synchronized boolean getWrite() {
- if (rc == 0) {
- return gotWrite();
- }
- ++wwc;
- return false;
+ if (rc == 0) {
+ return gotWrite();
+ }
+ ++wwc;
+ return false;
}
private synchronized boolean retryWrite() {
- if (stats != null) ++stats._wwc;
- if (rc == 0) {
- --wwc;
- return gotWrite();
- }
- return false;
+ if (stats != null) ++stats._wwc;
+ if (rc == 0) {
+ --wwc;
+ return gotWrite();
+ }
+ return false;
}
private static final int NOTIFY_NONE = 0;
@@ -185,17 +185,17 @@ public class ICURWLock {
private static final int NOTIFY_READERS = 2;
private synchronized int finishWrite() {
- if (rc < 0) {
- rc = 0;
- if (wwc > 0) {
- return NOTIFY_WRITERS;
- } else if (wrc > 0) {
- return NOTIFY_READERS;
- } else {
- return NOTIFY_NONE;
+ if (rc < 0) {
+ rc = 0;
+ if (wwc > 0) {
+ return NOTIFY_WRITERS;
+ } else if (wrc > 0) {
+ return NOTIFY_READERS;
+ } else {
+ return NOTIFY_NONE;
+ }
}
- }
- throw new InternalError("no current writer to release");
+ throw new IllegalStateException("no current writer to release");
}
/**
@@ -209,20 +209,20 @@ public class ICURWLock {
* releaseRead when done (for example, in a finally block).
*/
public void acquireRead() {
- if (!getRead()) {
- for (;;) {
- try {
- synchronized (readLock) {
- readLock.wait();
- }
- if (retryRead()) {
- return;
+ if (!getRead()) {
+ for (;;) {
+ try {
+ synchronized (readLock) {
+ readLock.wait();
+ }
+ if (retryRead()) {
+ return;
+ }
+ }
+ catch (InterruptedException e) {
+ }
}
}
- catch (InterruptedException e) {
- }
- }
- }
}
/**
@@ -234,12 +234,12 @@ public class ICURWLock {
* controlled by acquireRead.
*/
public void releaseRead() {
- if (finishRead()) {
- synchronized (writeLock) {
- writeLock.notify();
+ if (finishRead()) {
+ synchronized (writeLock) {
+ writeLock.notify();
+ }
}
}
- }
/**
* Acquire the write lock, blocking until the write lock is
@@ -253,20 +253,20 @@ public class ICURWLock {
* block).
*/
public void acquireWrite() {
- if (!getWrite()) {
- for (;;) {
- try {
- synchronized (writeLock) {
- writeLock.wait();
- }
- if (retryWrite()) {
- return;
+ if (!getWrite()) {
+ for (;;) {
+ try {
+ synchronized (writeLock) {
+ writeLock.wait();
+ }
+ if (retryWrite()) {
+ return;
+ }
+ }
+ catch (InterruptedException e) {
+ }
}
}
- catch (InterruptedException e) {
- }
- }
- }
}
/**
@@ -279,19 +279,19 @@ public class ICURWLock {
* acquireWrite.
*/
public void releaseWrite() {
- switch (finishWrite()) {
- case NOTIFY_WRITERS:
- synchronized (writeLock) {
- writeLock.notify();
+ switch (finishWrite()) {
+ case NOTIFY_WRITERS:
+ synchronized (writeLock) {
+ writeLock.notify();
+ }
+ break;
+ case NOTIFY_READERS:
+ synchronized (readLock) {
+ readLock.notifyAll();
+ }
+ break;
+ case NOTIFY_NONE:
+ break;
}
- break;
- case NOTIFY_READERS:
- synchronized (readLock) {
- readLock.notifyAll();
- }
- break;
- case NOTIFY_NONE:
- break;
- }
}
}
diff --git a/icu4j/src/com/ibm/icu/impl/ICUResourceBundleImpl.java b/icu4j/src/com/ibm/icu/impl/ICUResourceBundleImpl.java
index 38cabe5e05f..fec9b8122ca 100644
--- a/icu4j/src/com/ibm/icu/impl/ICUResourceBundleImpl.java
+++ b/icu4j/src/com/ibm/icu/impl/ICUResourceBundleImpl.java
@@ -111,7 +111,7 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
// genrb does not generate Table32 with %%ALIAS
return new ResourceTable32(null, rootResource, "", true);
} else {
- throw new InternalError("Invalid format error");
+ throw new IllegalStateException("Invalid format error");
}
}
private ICUResourceBundleImpl(ICUResourceBundleReader reader, String baseName,
@@ -183,7 +183,7 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
return new ResourceTable(key, resPath, resource);
}
default :
- throw new InternalError("The resource type is unknown");
+ throw new IllegalStateException("The resource type is unknown");
}
//}
//return null;
@@ -703,3 +703,4 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
return sub;
}
}
+
diff --git a/icu4j/src/com/ibm/icu/impl/ICUService.java b/icu4j/src/com/ibm/icu/impl/ICUService.java
index 368dcc85dcd..fea24eb6f3d 100644
--- a/icu4j/src/com/ibm/icu/impl/ICUService.java
+++ b/icu4j/src/com/ibm/icu/impl/ICUService.java
@@ -1,6 +1,6 @@
/**
*******************************************************************************
- * Copyright (C) 2001-2005, International Business Machines Corporation and *
+ * Copyright (C) 2001-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -433,7 +433,7 @@ public class ICUService extends ICUNotifier {
}
}
if (startIndex == 0) {
- throw new InternalError("Factory " + factory + "not registered with service: " + this);
+ throw new IllegalStateException("Factory " + factory + "not registered with service: " + this);
}
cacheResult = false;
}
diff --git a/icu4j/src/com/ibm/icu/impl/IntTrieBuilder.java b/icu4j/src/com/ibm/icu/impl/IntTrieBuilder.java
index 792356e4541..25fc349a026 100644
--- a/icu4j/src/com/ibm/icu/impl/IntTrieBuilder.java
+++ b/icu4j/src/com/ibm/icu/impl/IntTrieBuilder.java
@@ -1,6 +1,6 @@
/*
******************************************************************************
-* Copyright (C) 1996-2005, International Business Machines Corporation and *
+* Copyright (C) 1996-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
@@ -689,7 +689,7 @@ public class IntTrieBuilder extends TrieBuilder
block = allocDataBlock();
if (block < 0) {
// data table overflow
- throw new InternalError("Internal error: Out of memory space");
+ throw new IllegalStateException("Internal error: Out of memory space");
}
fillBlock(block, 0, DATA_BLOCK_LENGTH, m_leadUnitValue_, true);
// negative block number to indicate that it is a repeat block
@@ -788,4 +788,4 @@ public class IntTrieBuilder extends TrieBuilder
}
}
}
-
+
diff --git a/icu4j/src/com/ibm/icu/impl/PrettyPrinter.java b/icu4j/src/com/ibm/icu/impl/PrettyPrinter.java
index 388cdd9bcfd..86fb92a98da 100644
--- a/icu4j/src/com/ibm/icu/impl/PrettyPrinter.java
+++ b/icu4j/src/com/ibm/icu/impl/PrettyPrinter.java
@@ -1,6 +1,6 @@
/**
*******************************************************************************
- * Copyright (C) 1996-2005, international Business Machines Corporation and *
+ * Copyright (C) 1996-2006, international Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -128,7 +128,7 @@ public class PrettyPrinter {
String sresult = target.toString();
UnicodeSet doubleCheck = new UnicodeSet(sresult);
if (!uset.equals(doubleCheck)) {
- throw new InternalError("Failure to round-trip in pretty-print");
+ throw new IllegalStateException("Failure to round-trip in pretty-print");
}
return sresult;
}
@@ -230,4 +230,4 @@ public class PrettyPrinter {
// public String toString() {
// return target.toString();
// }
-}
\ No newline at end of file
+}
diff --git a/icu4j/src/com/ibm/icu/impl/UPropertyAliases.java b/icu4j/src/com/ibm/icu/impl/UPropertyAliases.java
index 20f3d46973d..b12cfe9307c 100644
--- a/icu4j/src/com/ibm/icu/impl/UPropertyAliases.java
+++ b/icu4j/src/com/ibm/icu/impl/UPropertyAliases.java
@@ -1,6 +1,6 @@
/*
**********************************************************************
-* Copyright (c) 2002-2005, International Business Machines
+* Copyright (c) 2002-2006, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
@@ -585,8 +585,8 @@ public final class UPropertyAliases implements ICUBinary.Authenticate {
return (short) ((offset < 0) ? -i : i);
}
}
- throw new InternalError("Can't map string pool offset " + offset +
- " to index");
+ throw new IllegalStateException("Can't map string pool offset " +
+ offset + " to index");
}
/**
@@ -612,8 +612,8 @@ public final class UPropertyAliases implements ICUBinary.Authenticate {
return i;
}
}
- throw new InternalError("Can't map value map offset " + offset +
- " to index");
+ throw new IllegalStateException("Can't map value map offset " +
+ offset + " to index");
}
/**
diff --git a/icu4j/src/com/ibm/icu/impl/Utility.java b/icu4j/src/com/ibm/icu/impl/Utility.java
index 118ff94d8c0..628b3f94918 100755
--- a/icu4j/src/com/ibm/icu/impl/Utility.java
+++ b/icu4j/src/com/ibm/icu/impl/Utility.java
@@ -472,7 +472,7 @@ public final class Utility {
}
if (ai != length || i != maxI) {
- throw new InternalError("Bad run-length encoded int array");
+ throw new IllegalStateException("Bad run-length encoded int array");
}
return array;
@@ -508,7 +508,7 @@ public final class Utility {
}
if (ai != length)
- throw new InternalError("Bad run-length encoded short array");
+ throw new IllegalStateException("Bad run-length encoded short array");
return array;
}
@@ -539,7 +539,7 @@ public final class Utility {
}
if (ai != length)
- throw new InternalError("Bad run-length encoded short array");
+ throw new IllegalStateException("Bad run-length encoded short array");
return array;
}
@@ -609,10 +609,10 @@ public final class Utility {
}
if (node != 0)
- throw new InternalError("Bad run-length encoded byte array");
+ throw new IllegalStateException("Bad run-length encoded byte array");
if (i != s.length())
- throw new InternalError("Excess data in RLE byte array string");
+ throw new IllegalStateException("Excess data in RLE byte array string");
return array;
}
diff --git a/icu4j/src/com/ibm/icu/lang/UCharacter.java b/icu4j/src/com/ibm/icu/lang/UCharacter.java
index 31e14d2992c..7cd762de35b 100755
--- a/icu4j/src/com/ibm/icu/lang/UCharacter.java
+++ b/icu4j/src/com/ibm/icu/lang/UCharacter.java
@@ -1820,8 +1820,8 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
};
static {
- if(COUNT!=BLOCKS_.length) {
- throw new java.lang.InternalError("UnicodeBlock fields are inconsistent!");
+ if (COUNT!=BLOCKS_.length) {
+ throw new java.lang.IllegalStateException("UnicodeBlock fields are inconsistent!");
}
}
/**
diff --git a/icu4j/src/com/ibm/icu/lang/UScript.java b/icu4j/src/com/ibm/icu/lang/UScript.java
index 4512d9f35c6..296389fd0fd 100755
--- a/icu4j/src/com/ibm/icu/lang/UScript.java
+++ b/icu4j/src/com/ibm/icu/lang/UScript.java
@@ -421,7 +421,8 @@ public final class UScript {
}
if (w < result.length) {
- throw new InternalError("bad locale data, listed " + result.length + " scripts but found only " + w);
+ throw new IllegalStateException("bad locale data, listed " +
+ result.length + " scripts but found only " + w);
}
return result;
diff --git a/icu4j/src/com/ibm/icu/text/BreakIterator.java b/icu4j/src/com/ibm/icu/text/BreakIterator.java
index c12b8aa0073..19771b04df4 100755
--- a/icu4j/src/com/ibm/icu/text/BreakIterator.java
+++ b/icu4j/src/com/ibm/icu/text/BreakIterator.java
@@ -228,7 +228,7 @@ public abstract class BreakIterator implements Cloneable
}
catch (CloneNotSupportedException e) {
///CLOVER:OFF
- throw new InternalError();
+ throw new IllegalStateException();
///CLOVER:ON
}
}
diff --git a/icu4j/src/com/ibm/icu/text/BreakTransliterator.java b/icu4j/src/com/ibm/icu/text/BreakTransliterator.java
index c0a95355bb7..e7a7548ae70 100644
--- a/icu4j/src/com/ibm/icu/text/BreakTransliterator.java
+++ b/icu4j/src/com/ibm/icu/text/BreakTransliterator.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 1996-2005, International Business Machines Corporation and *
+ * Copyright (C) 1996-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -374,7 +374,7 @@ final class BreakTransliterator extends Transliterator {
return other;
}
catch (CloneNotSupportedException e) {
- throw new InternalError();
+ throw new IllegalStateException();
}
}
diff --git a/icu4j/src/com/ibm/icu/text/CollatorServiceShim.java b/icu4j/src/com/ibm/icu/text/CollatorServiceShim.java
index cdd8fc9c647..9e2f4464c3a 100644
--- a/icu4j/src/com/ibm/icu/text/CollatorServiceShim.java
+++ b/icu4j/src/com/ibm/icu/text/CollatorServiceShim.java
@@ -1,6 +1,6 @@
/**
*******************************************************************************
-* Copyright (C) 2003-2005, International Business Machines Corporation and *
+* Copyright (C) 2003-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -41,7 +41,7 @@ final class CollatorServiceShim extends Collator.ServiceShim {
}
catch (CloneNotSupportedException e) {
///CLOVER:OFF
- throw new InternalError(e.getMessage());
+ throw new IllegalStateException(e.getMessage());
///CLOVER:ON
}
}
diff --git a/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java b/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java
index 00e5e0a4dbf..980df474b80 100755
--- a/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java
+++ b/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java
@@ -709,7 +709,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
return other;
} catch (CloneNotSupportedException e) {
///CLOVER:OFF
- throw new InternalError();
+ throw new IllegalStateException();
///CLOVER:ON
}
}
diff --git a/icu4j/src/com/ibm/icu/text/DecimalFormat.java b/icu4j/src/com/ibm/icu/text/DecimalFormat.java
index 044ca29c58b..c1704a7b9a8 100755
--- a/icu4j/src/com/ibm/icu/text/DecimalFormat.java
+++ b/icu4j/src/com/ibm/icu/text/DecimalFormat.java
@@ -2732,7 +2732,7 @@ public class DecimalFormat extends NumberFormat {
other.symbols = (DecimalFormatSymbols) symbols.clone();
return other;
} catch (Exception e) {
- throw new InternalError();
+ throw new IllegalStateException();
}
}
diff --git a/icu4j/src/com/ibm/icu/text/DecimalFormatSymbols.java b/icu4j/src/com/ibm/icu/text/DecimalFormatSymbols.java
index 8182f7ddeeb..73e9867f256 100755
--- a/icu4j/src/com/ibm/icu/text/DecimalFormatSymbols.java
+++ b/icu4j/src/com/ibm/icu/text/DecimalFormatSymbols.java
@@ -526,7 +526,7 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
// other fields are bit-copied
} catch (CloneNotSupportedException e) {
///CLOVER:OFF
- throw new InternalError();
+ throw new IllegalStateException();
///CLOVER:ON
}
}
diff --git a/icu4j/src/com/ibm/icu/text/Normalizer.java b/icu4j/src/com/ibm/icu/text/Normalizer.java
index fd9f78d5609..535655e6996 100755
--- a/icu4j/src/com/ibm/icu/text/Normalizer.java
+++ b/icu4j/src/com/ibm/icu/text/Normalizer.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 2000-2005, International Business Machines Corporation and *
+ * Copyright (C) 2000-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -806,7 +806,7 @@ public final class Normalizer implements Cloneable {
this.mode = mode;
this.options = options;
} catch (CloneNotSupportedException e) {
- throw new InternalError(e.toString());
+ throw new IllegalStateException(e.toString());
}
}
@@ -832,7 +832,7 @@ public final class Normalizer implements Cloneable {
return copy;
}
catch (CloneNotSupportedException e) {
- throw new InternalError(e.toString());
+ throw new IllegalStateException(e.toString());
}
}
@@ -2104,7 +2104,7 @@ public final class Normalizer implements Cloneable {
UCharacterIterator newIter = UCharacterIterator.getInstance(newText);
if (newIter == null) {
- throw new InternalError("Could not create a new UCharacterIterator");
+ throw new IllegalStateException("Could not create a new UCharacterIterator");
}
text = newIter;
reset();
@@ -2120,7 +2120,7 @@ public final class Normalizer implements Cloneable {
UCharacterIterator newIter = UCharacterIterator.getInstance(newText);
if (newIter == null) {
- throw new InternalError("Could not create a new UCharacterIterator");
+ throw new IllegalStateException("Could not create a new UCharacterIterator");
}
text = newIter;
reset();
@@ -2136,7 +2136,7 @@ public final class Normalizer implements Cloneable {
UCharacterIterator newIter = UCharacterIterator.getInstance(newText);
if (newIter == null) {
- throw new InternalError("Could not create a new UCharacterIterator");
+ throw new IllegalStateException("Could not create a new UCharacterIterator");
}
text = newIter;
reset();
@@ -2152,7 +2152,7 @@ public final class Normalizer implements Cloneable {
UCharacterIterator newIter = UCharacterIterator.getInstance(newText);
if (newIter == null) {
- throw new InternalError("Could not create a new UCharacterIterator");
+ throw new IllegalStateException("Could not create a new UCharacterIterator");
}
text = newIter;
reset();
@@ -2168,12 +2168,12 @@ public final class Normalizer implements Cloneable {
try{
UCharacterIterator newIter = (UCharacterIterator)newText.clone();
if (newIter == null) {
- throw new InternalError("Could not create a new UCharacterIterator");
+ throw new IllegalStateException("Could not create a new UCharacterIterator");
}
text = newIter;
reset();
}catch(CloneNotSupportedException e) {
- throw new InternalError("Could not clone the UCharacterIterator");
+ throw new IllegalStateException("Could not clone the UCharacterIterator");
}
}
diff --git a/icu4j/src/com/ibm/icu/text/Punycode.java b/icu4j/src/com/ibm/icu/text/Punycode.java
index be74fc514a6..f27a5b2a2c3 100644
--- a/icu4j/src/com/ibm/icu/text/Punycode.java
+++ b/icu4j/src/com/ibm/icu/text/Punycode.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 2003-2005, International Business Machines Corporation and *
+ * Copyright (C) 2003-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -215,7 +215,7 @@ final class Punycode {
* state to , but guard against overflow:
*/
if(m-n>(0x7fffffff-MAX_CP_COUNT-delta)/(handledCPCount+1)) {
- throw new InternalError("Internal program error");
+ throw new IllegalStateException("Internal program error");
}
delta+=(m-n)*(handledCPCount+1);
n=m;
diff --git a/icu4j/src/com/ibm/icu/text/RBNFChinesePostProcessor.java b/icu4j/src/com/ibm/icu/text/RBNFChinesePostProcessor.java
index 3ec007eaeaa..c1854cfa905 100644
--- a/icu4j/src/com/ibm/icu/text/RBNFChinesePostProcessor.java
+++ b/icu4j/src/com/ibm/icu/text/RBNFChinesePostProcessor.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 2004-2005, International Business Machines Corporation and *
+ * Copyright (C) 2004-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -146,7 +146,7 @@ final class RBNFChinesePostProcessor extends RBNFPostProcessor {
n = -1;
break;
default:
- throw new InternalError();
+ throw new IllegalStateException();
}
}
diff --git a/icu4j/src/com/ibm/icu/text/RuleBasedCollator.java b/icu4j/src/com/ibm/icu/text/RuleBasedCollator.java
index 38111cee766..bf03c70dd9b 100755
--- a/icu4j/src/com/ibm/icu/text/RuleBasedCollator.java
+++ b/icu4j/src/com/ibm/icu/text/RuleBasedCollator.java
@@ -728,7 +728,8 @@ public final class RuleBasedCollator extends Collator
CollationRuleParser src = new CollationRuleParser(getRules());
return src.getTailoredSet();
} catch(Exception e) {
- throw new InternalError("A tailoring rule should not have errors. Something is quite wrong!");
+ throw new IllegalStateException("A tailoring rule should not " +
+ "have errors. Something is quite wrong!");
}
}
diff --git a/icu4j/src/com/ibm/icu/text/StringCharacterIterator.java b/icu4j/src/com/ibm/icu/text/StringCharacterIterator.java
index e4189224f1d..00fa60f65bf 100755
--- a/icu4j/src/com/ibm/icu/text/StringCharacterIterator.java
+++ b/icu4j/src/com/ibm/icu/text/StringCharacterIterator.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 1996-2004, International Business Machines Corporation and *
+ * Copyright (C) 1996-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -273,7 +273,7 @@ public final class StringCharacterIterator implements CharacterIterator
return other;
}
catch (CloneNotSupportedException e) {
- throw new InternalError();
+ throw new IllegalStateException();
}
}
diff --git a/icu4j/src/com/ibm/icu/text/UnicodeSet.java b/icu4j/src/com/ibm/icu/text/UnicodeSet.java
index aefe4077c81..7e90ac21a0d 100755
--- a/icu4j/src/com/ibm/icu/text/UnicodeSet.java
+++ b/icu4j/src/com/ibm/icu/text/UnicodeSet.java
@@ -2801,7 +2801,7 @@ public class UnicodeSet extends UnicodeFilter {
}
break;
default:
- throw new InternalError("UnicodeSet.getInclusions(unknown src "+src+")");
+ throw new IllegalStateException("UnicodeSet.getInclusions(unknown src "+src+")");
}
INCLUSIONS[src] = incl;
}
diff --git a/icu4j/src/com/ibm/icu/util/Calendar.java b/icu4j/src/com/ibm/icu/util/Calendar.java
index a46b127560b..890670bf8e2 100755
--- a/icu4j/src/com/ibm/icu/util/Calendar.java
+++ b/icu4j/src/com/ibm/icu/util/Calendar.java
@@ -1553,7 +1553,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable {
// todo: fix, difficult to test without subclassing
if (fields == null || fields.length < BASE_FIELD_COUNT ||
fields.length > MAX_FIELD_COUNT) {
- throw new InternalError("Invalid fields[]");
+ throw new IllegalStateException("Invalid fields[]");
}
///CLOVER:ON
stamp = new int[fields.length];
@@ -1685,7 +1685,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable {
case JAPANESE:
return new JapaneseCalendar(zone, locale);
default:
- throw new InternalError();
+ throw new IllegalStateException();
}
} else {
Calendar result = factory.create(zone, locale);
@@ -3814,7 +3814,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable {
}
catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
- throw new InternalError();
+ throw new IllegalStateException();
}
}
@@ -4880,8 +4880,8 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable {
*/
protected final void internalSet(int field, int value) {
if (((1 << field) & internalSetMask) == 0) {
- throw new InternalError("Subclass cannot set " +
- fieldName(field));
+ throw new IllegalStateException("Subclass cannot set " +
+ fieldName(field));
}
fields[field] = value;
stamp[field] = INTERNALLY_SET;
diff --git a/icu4j/src/com/ibm/icu/util/CompactByteArray.java b/icu4j/src/com/ibm/icu/util/CompactByteArray.java
index 63b02ec40c6..f025e573c28 100755
--- a/icu4j/src/com/ibm/icu/util/CompactByteArray.java
+++ b/icu4j/src/com/ibm/icu/util/CompactByteArray.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 1996-2004, International Business Machines Corporation and *
+ * Copyright (C) 1996-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -287,7 +287,7 @@ public final class CompactByteArray implements Cloneable {
if (hashes != null) other.hashes = (int[])hashes.clone();
return other;
} catch (CloneNotSupportedException e) {
- throw new InternalError();
+ throw new IllegalStateException();
}
}
diff --git a/icu4j/src/com/ibm/icu/util/CompactCharArray.java b/icu4j/src/com/ibm/icu/util/CompactCharArray.java
index 7da774940db..04dabfb5b65 100755
--- a/icu4j/src/com/ibm/icu/util/CompactCharArray.java
+++ b/icu4j/src/com/ibm/icu/util/CompactCharArray.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 1996-2004, International Business Machines Corporation and *
+ * Copyright (C) 1996-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -311,7 +311,7 @@ public final class CompactCharArray implements Cloneable {
if (hashes != null) other.hashes = (int[])hashes.clone();
return other;
} catch (CloneNotSupportedException e) {
- throw new InternalError();
+ throw new IllegalStateException();
}
}
diff --git a/icu4j/src/com/ibm/icu/util/GlobalizationPreferences.java b/icu4j/src/com/ibm/icu/util/GlobalizationPreferences.java
index d260c3b5c20..5fdec2b56a8 100644
--- a/icu4j/src/com/ibm/icu/util/GlobalizationPreferences.java
+++ b/icu4j/src/com/ibm/icu/util/GlobalizationPreferences.java
@@ -388,7 +388,7 @@ public class GlobalizationPreferences implements Freezable {
try {
return (Collator) collator.clone(); // clone for safety
} catch (CloneNotSupportedException e) {
- throw new InternalError("Error in cloning collator");
+ throw new IllegalStateException("Error in cloning collator");
}
}
diff --git a/icu4j/src/com/ibm/icu/util/TimeZone.java b/icu4j/src/com/ibm/icu/util/TimeZone.java
index 7a58ccbe070..088dbce0fa2 100755
--- a/icu4j/src/com/ibm/icu/util/TimeZone.java
+++ b/icu4j/src/com/ibm/icu/util/TimeZone.java
@@ -745,7 +745,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
other.ID = ID;
return other;
} catch (CloneNotSupportedException e) {
- throw new InternalError();
+ throw new IllegalStateException();
}
}
diff --git a/icu4j/src/com/ibm/icu/util/UResourceBundle.java b/icu4j/src/com/ibm/icu/util/UResourceBundle.java
index 29f1b9d02e6..e19505d5eda 100644
--- a/icu4j/src/com/ibm/icu/util/UResourceBundle.java
+++ b/icu4j/src/com/ibm/icu/util/UResourceBundle.java
@@ -372,7 +372,7 @@ public abstract class UResourceBundle extends ResourceBundle{
return super.clone();
} catch (CloneNotSupportedException e) {
//this should never happen
- throw new InternalError();
+ throw new IllegalStateException();
}
}
///CLOVER:ON