687 * @exception IOException if an error is encountered.
688 */
689 void unpack(File in, JarOutputStream out) throws IOException;
690 }
691
692 // Private stuff....
693
694 private static final String PACK_PROVIDER = "java.util.jar.Pack200.Packer";
695 private static final String UNPACK_PROVIDER = "java.util.jar.Pack200.Unpacker";
696
697 private static Class<?> packerImpl;
698 private static Class<?> unpackerImpl;
699
700 private static synchronized Object newInstance(String prop) {
701 String implName = "(unknown)";
702 try {
703 Class<?> impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
704 if (impl == null) {
705 // The first time, we must decide which class to use.
706 implName = GetPropertyAction.privilegedGetProperty(prop,"");
707 if (implName != null && !implName.equals(""))
708 impl = Class.forName(implName);
709 else if (PACK_PROVIDER.equals(prop))
710 impl = com.sun.java.util.jar.pack.PackerImpl.class;
711 else
712 impl = com.sun.java.util.jar.pack.UnpackerImpl.class;
713 }
714 // We have a class. Now instantiate it.
715 @SuppressWarnings("deprecation")
716 Object result = impl.newInstance();
717 return result;
718 } catch (ClassNotFoundException e) {
719 throw new Error("Class not found: " + implName +
720 ":\ncheck property " + prop +
721 " in your properties file.", e);
722 } catch (InstantiationException e) {
723 throw new Error("Could not instantiate: " + implName +
724 ":\ncheck property " + prop +
725 " in your properties file.", e);
726 } catch (IllegalAccessException e) {
727 throw new Error("Cannot access class: " + implName +
|
687 * @exception IOException if an error is encountered.
688 */
689 void unpack(File in, JarOutputStream out) throws IOException;
690 }
691
692 // Private stuff....
693
694 private static final String PACK_PROVIDER = "java.util.jar.Pack200.Packer";
695 private static final String UNPACK_PROVIDER = "java.util.jar.Pack200.Unpacker";
696
697 private static Class<?> packerImpl;
698 private static Class<?> unpackerImpl;
699
700 private static synchronized Object newInstance(String prop) {
701 String implName = "(unknown)";
702 try {
703 Class<?> impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
704 if (impl == null) {
705 // The first time, we must decide which class to use.
706 implName = GetPropertyAction.privilegedGetProperty(prop,"");
707 if (implName != null && !implName.isEmpty())
708 impl = Class.forName(implName);
709 else if (PACK_PROVIDER.equals(prop))
710 impl = com.sun.java.util.jar.pack.PackerImpl.class;
711 else
712 impl = com.sun.java.util.jar.pack.UnpackerImpl.class;
713 }
714 // We have a class. Now instantiate it.
715 @SuppressWarnings("deprecation")
716 Object result = impl.newInstance();
717 return result;
718 } catch (ClassNotFoundException e) {
719 throw new Error("Class not found: " + implName +
720 ":\ncheck property " + prop +
721 " in your properties file.", e);
722 } catch (InstantiationException e) {
723 throw new Error("Could not instantiate: " + implName +
724 ":\ncheck property " + prop +
725 " in your properties file.", e);
726 } catch (IllegalAccessException e) {
727 throw new Error("Cannot access class: " + implName +
|