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