ICU4J

ICU4J is a set of Java libraries that provides more comprehensive support for Unicode, software globalization, and internationalization. In order to provide this functionality to the Eclipse community, ICU4J was added to the Eclipse platform build for the 3.2 M4 milestone. You will see it in the build as a plugin named com.ibm.icu. The Eclipse platform will be utilizing the ICU APIs for Eclipse 3.2.

Contents

Migration

This section describes how to adopt ICU4J into your application.

Migration of application code can be done incrementally, meaning full adoption of all ICU4J function is not necessary to reap the benefits of using ICU4J. Migration can be done in the following four sequential steps:

1. Import changes

Some classes need only be replaced with the ICU equivalent class by changing the import statement (i.e. change java.* with com.ibm.icu.*).

Note: classes UCharacter, UResourceBundle, and UFormat are not implemented in the replacement plug-in (see below) so if your application’s code needs to work with both the replacement plug-in and the real ICU4J plug-in then you will not be able to adopt these classes at this time.

3. Re-structure

Some code needs to be re-written to take utilize ICU function. Discovering code that needs to be re-structured in this manner will not be as systematic as in the previous two steps.

Example: use com.ibm.icu.text.BreakIterator to locate boundaries in text instead of iterating over a string and using java.lang.Character.isLetterOrDigit(string.charAt(idx)).

4. Utilize New Features

ICU adds additional function in some areas that is not provided by the JDK. In this case, new code would need to be written to take advantage of these new features.

Example: the class com.ibm.icu.text.Transliterator

Replacement Plug-in

The Eclipse SDK will be adopting the ICU4J APIs for Eclipse 3.2. The addition of the ICU4J plug-in adds on the order of 3MB worth of code. Some applications may not want to absorb ICU4J if the priority is size over adopting the ICU4J function. If this is the case for your application, you can download the replacement plug-in (com.ibm.icu.base) from the build page from which you obtained your Eclipse build, remove the com.ibm.icu plug-in and its source counterpart, and drop in the replacement plug-in. This is required because the Platform adopted the ICU APIs for 3.2 and so just removing the ICU plug-in will result in compilation errors. The replacement plug-in is about 100KB in size and simply calls through to the java.* packages (default JDK implementation) of the most commonly used classes and APIs in ICU4J. The classes that are implemented in the replacement plug-in are as follows:

BreakIterator

CollationKey

Collator

DateFormat

DateFormatSymbols

DecimalFormat

DecimalFormatSymbols

NumberFormat

SimpleDateFormat

StringTokenizer

Calendar

TimeZone

ULocale

MessageFormat

If your application needs to be compatible between both the ICU4J plug-in and the replacement plug-in (most often for size reasons), we recommend you only use the API in the classes from this list. If ICU4J is guaranteed to always be present in the application then you can safely use any of the ICU4J APIs. The replacement plug-in will be built separately and available as a download on the build pages, but this is still work in progress. You can however, start using the ICU4J APIs since the ICU4J plug-in is currently in the SDK build as of M4 (and beyond).

If you choose to adopt ICU4J, it is recommended that, in your plug-in manifest file, instead of using the Require-Bundle header to specify the dependency on ICU4J (e.g.)

Require-Bundle: com.ibm.icu

you use the Import-Package header to specify your plug-in's dependency on ICU4J (e.g.).

Import-Package: com.ibm.icu.text,
com.ibm.icu.util

This is to ensure you will not encounter compile or runtime errors if you decide to use the replacement plug-in instead of the full ICU4J plug-in, or vice-versa.

Bugs in ICU4J

Bugs that are found in ICU4J should not be logged against Eclipse products or components, they should be logged against the ICU project at: