ICU-5605 ensured java 1.3 compatibility, removed reliance on UResourceBundle being in the classpath, various minor fixes
X-SVN-Rev: 21317
This commit is contained in:
parent
f5f32c1594
commit
d680f4f21f
@ -101,6 +101,7 @@
|
||||
<property name="tzu.bin.dir" value="${basedir}/icu4jtzu" />
|
||||
<property name="tzujar.file" value="${tzu.bin.dir}/icutzu.jar" />
|
||||
<property name="tzu.test.dir" value="${basedir}/icu4jtzu/test" />
|
||||
<property name="tzu.temp.dir" value="${basedir}/icu4jtzu/tmp" />
|
||||
<property file="build.properties" />
|
||||
<!-- fix the data folder every time there is a version update-->
|
||||
|
||||
@ -2101,7 +2102,7 @@
|
||||
<fileset dir="${basedir}" includes="license.html" />
|
||||
<fileset dir="${build.dir}" includes="com/ibm/icu/dev/tool/tzu/**/*.class" />
|
||||
<manifest>
|
||||
<!-- attribute name="Main-Class" value="com.ibm.icu.dev.tool.tzu.ICUTZUMain" / -->
|
||||
<attribute name="Main-Class" value="com.ibm.icu.dev.tool.tzu.ICUTZUMain" />
|
||||
<attribute name="Built-By" value="${corp}" />
|
||||
<section name="common">
|
||||
<attribute name="Specification-Title" value="ICU4J TimeZone Update Utility" />
|
||||
@ -2121,6 +2122,11 @@
|
||||
|
||||
<target name="icutzucheck" depends="icutzujar" description="check ICU4J TimeZone Update Utility">
|
||||
<echo>Testing ICUTZU ...</echo>
|
||||
|
||||
<mkdir dir="${tzu.temp.dir}" />
|
||||
<copy todir="${tzu.temp.dir}" file="${tzu.bin.dir}/DirectorySearch.txt" />
|
||||
<copy todir="${tzu.temp.dir}" file="${tzu.bin.dir}/zoneinfo.res" />
|
||||
|
||||
<get dest="${tzu.bin.dir}/zoneinfo.res" src="http://source.icu-project.org/repos/icu/data/trunk/tzdata/icu/2006a/be/zoneinfo.res" />
|
||||
<copy todir="${tzu.test.dir}" file="${tzu.bin.dir}/icu4j.jar" />
|
||||
<echo file="${tzu.bin.dir}/DirectorySearch.txt">+${tzu.test.dir}</echo>
|
||||
@ -2159,6 +2165,12 @@
|
||||
<arg value="icu.gif" />
|
||||
</exec>
|
||||
|
||||
<delete file="${tzu.bin.dir}/zoneinfo.res" />
|
||||
<delete file="${tzu.bin.dir}/DirectorySearch.txt" />
|
||||
<copy todir="${tzu.bin.dir}" file="${tzu.temp.dir}/zoneinfo.res" />
|
||||
<copy todir="${tzu.bin.dir}" file="${tzu.temp.dir}/DirectorySearch.txt" />
|
||||
<delete dir="${tzu.temp.dir}" />
|
||||
|
||||
<echo>Comparing results ...</echo>
|
||||
<unjar src="${tzu.test.dir}/icu4j.jar" dest="${tzu.test.dir}">
|
||||
<patternset>
|
||||
|
@ -13,6 +13,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
@ -25,8 +27,6 @@ import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import com.ibm.icu.util.UResourceBundle;
|
||||
|
||||
/**
|
||||
* A class that represents an updatable ICU4J jar file. A file is an updatable
|
||||
* ICU4J jar file if it
|
||||
@ -98,7 +98,7 @@ public class ICUFile {
|
||||
File temp = File.createTempFile("zoneinfo", ".res");
|
||||
temp.deleteOnExit();
|
||||
rawTZFile.copyFile(tzFile, temp);
|
||||
return findTZVersion(temp);
|
||||
return findTZVersion(temp, logger);
|
||||
} catch (IOException ex) {
|
||||
logger.errorln(ex.getMessage());
|
||||
return null;
|
||||
@ -111,29 +111,60 @@ public class ICUFile {
|
||||
*
|
||||
* @param tzFile
|
||||
* The file representing the timezone resource.
|
||||
* @param logger
|
||||
* The current logger.
|
||||
* @return The version of the timezone resource.
|
||||
*/
|
||||
private static String findTZVersion(File tzFile) {
|
||||
private static String findTZVersion(File tzFile, Logger logger) {
|
||||
try {
|
||||
String filename = tzFile.getName();
|
||||
String entryname = filename.substring(0, filename.length()
|
||||
- ".res".length());
|
||||
|
||||
URL url = new URL(tzFile.getParentFile().toURL().toString());
|
||||
URL url = new URL(tzFile.getAbsoluteFile().getParentFile().toURL()
|
||||
.toString());
|
||||
ClassLoader loader = new URLClassLoader(new URL[] { url });
|
||||
|
||||
UResourceBundle bundle = UResourceBundle.getBundleInstance("",
|
||||
entryname, loader);
|
||||
// UResourceBundle bundle = UResourceBundle.getBundleInstance("",
|
||||
// entryname, loader);
|
||||
|
||||
String tzVersion;
|
||||
if (bundle != null
|
||||
&& (tzVersion = bundle.getString(TZ_VERSION_KEY)) != null)
|
||||
return tzVersion;
|
||||
} catch (MissingResourceException ex) {
|
||||
// not an error -- some zoneinfo files do not have a version number
|
||||
URL bundleURL = new URL(new File("icu4j.jar").toURL().toString());
|
||||
URLClassLoader bundleLoader = new URLClassLoader(
|
||||
new URL[] { bundleURL });
|
||||
Class bundleClass = bundleLoader
|
||||
.loadClass("com.ibm.icu.util.UResourceBundle");
|
||||
Method bundleGetInstance = bundleClass.getMethod(
|
||||
"getBundleInstance", new Class[] { String.class,
|
||||
String.class, ClassLoader.class });
|
||||
Object bundle = bundleGetInstance.invoke(null, new Object[] { "",
|
||||
entryname, loader });
|
||||
|
||||
if (bundle != null) {
|
||||
Method bundleGetString = bundleClass.getMethod("getString",
|
||||
new Class[] { String.class });
|
||||
String tzVersion = (String) bundleGetString.invoke(bundle,
|
||||
new Object[] { TZ_VERSION_KEY });
|
||||
if (tzVersion != null)
|
||||
return tzVersion;
|
||||
}
|
||||
} catch (MalformedURLException ex) {
|
||||
// this should never happen
|
||||
ex.printStackTrace();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
// this would most likely happen when UResourceBundle cannot be
|
||||
// resolved, which is when icu4j.jar is not where it should be
|
||||
logger.errorln("icu4j.jar not found");
|
||||
} catch (NoSuchMethodException ex) {
|
||||
// this can only be caused by a very unlikely scenario
|
||||
ex.printStackTrace();
|
||||
} catch (IllegalAccessException ex) {
|
||||
// this can only be caused by a very unlikely scenario
|
||||
ex.printStackTrace();
|
||||
} catch (InvocationTargetException ex) {
|
||||
// if this is holding a MissingResourceException, then this is not
|
||||
// an error -- some zoneinfo files do not have a version number
|
||||
if (!(ex.getTargetException() instanceof MissingResourceException))
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return TZ_VERSION_UNKNOWN;
|
||||
@ -249,7 +280,7 @@ public class ICUFile {
|
||||
File temp = File.createTempFile("zoneinfo", ".res");
|
||||
temp.deleteOnExit();
|
||||
copyEntry(icuFile, tzEntry, temp);
|
||||
return findTZVersion(temp);
|
||||
return findTZVersion(temp, logger);
|
||||
} catch (IOException ex) {
|
||||
logger.errorln(ex.getMessage());
|
||||
return null;
|
||||
@ -289,7 +320,7 @@ public class ICUFile {
|
||||
* @return The path of this ICUFile object, without the filename.
|
||||
*/
|
||||
public String getPath() {
|
||||
return icuFile.getParent();
|
||||
return icuFile.getAbsoluteFile().getParent();
|
||||
}
|
||||
|
||||
// public static String findURLTZVersion(File tzFile) {
|
||||
@ -504,8 +535,8 @@ public class ICUFile {
|
||||
backupBase.mkdir();
|
||||
backupDir.mkdir();
|
||||
backupFile = File.createTempFile(prefix, suffix, backupDir);
|
||||
backupDesc = new File(backupDir.toString() + File.separator
|
||||
+ prefix + ".txt");
|
||||
backupDesc = new File(backupDir.getPath() + File.separator + prefix
|
||||
+ ".txt");
|
||||
backupDesc.createNewFile();
|
||||
ostream = new PrintStream(new FileOutputStream(backupDesc));
|
||||
ostream.println(inputFile.toString());
|
||||
|
Loading…
Reference in New Issue
Block a user