src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java
Print this page
@@ -77,31 +77,35 @@
/**
* Takes a JarFile and converts into a pack-stream.
* <p>
* Closes its input but not its output. (Pack200 archives are appendable.)
+ *
* @param in a JarFile
* @param out an OutputStream
* @exception IOException if an error is encountered.
*/
public synchronized void pack(JarFile in, OutputStream out) throws IOException {
- assert(Utils.currentInstance.get() == null);
- TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
- ? null
- : TimeZone.getDefault();
+ assert (Utils.currentInstance.get() == null);
+
+ boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE);
try {
Utils.currentInstance.set(this);
- if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ if (needUTC) {
+ Utils.changeDefaultTimeZoneToUtc();
+ }
if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
Utils.copyJarFile(in, out);
} else {
(new DoPack()).run(in, out);
}
} finally {
Utils.currentInstance.set(null);
- if (tz != null) TimeZone.setDefault(tz);
+ if (needUTC) {
+ Utils.restoreDefaultTimeZone();
+ }
in.close();
}
}
/**
@@ -117,27 +121,31 @@
* @param in a JarInputStream
* @param out an OutputStream
* @exception IOException if an error is encountered.
*/
public synchronized void pack(JarInputStream in, OutputStream out) throws IOException {
- assert(Utils.currentInstance.get() == null);
- TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null :
- TimeZone.getDefault();
+ assert (Utils.currentInstance.get() == null);
+ boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE);
try {
Utils.currentInstance.set(this);
- if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ if (needUTC) {
+ Utils.changeDefaultTimeZoneToUtc();
+ }
if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
Utils.copyJarFile(in, out);
} else {
(new DoPack()).run(in, out);
}
} finally {
Utils.currentInstance.set(null);
- if (tz != null) TimeZone.setDefault(tz);
+ if (needUTC) {
+ Utils.restoreDefaultTimeZone();
+ }
in.close();
}
}
+
/**
* Register a listener for changes to options.
* @param listener An object to be invoked when a property is changed.
*/
public void addPropertyChangeListener(PropertyChangeListener listener) {