if (orig != null && orig.getClass().getName().equals(StreamHandlerFactory.class.getName())) throw new Error("Multiple URLStreamHandlerFactories not supported.");
if (factory != null) { try { factory.getClass().getMethod("isMultiplexing", null); Method register = factory.getClass().getMethod("register", new Class[] {Object.class}); register.invoke(factory, new Object[] {shf}); } catch (NoSuchMethodException e) {  shf.setParentFactory(factory); factory = shf; } }
	private static void forceURLStreamHandlerFactory(StreamHandlerFactory shf) throws Exception{		Field factoryField = getStaticField(URL.class, URLStreamHandlerFactory.class);		if (factoryField == null)			throw new Exception("Could not find URLStreamHandlerFactory field"); //$NON-NLS-1$		// look for a lock to synchronize on		Object lock;		try {			Field streamHandlerLockField = URL.class.getDeclaredField("streamHandlerLock"); //$NON-NLS-1$			streamHandlerLockField.setAccessible(true);			lock = streamHandlerLockField.get(null);		} catch (NoSuchFieldException noField) {			// could not find the lock, lets sync on the class object			lock = URL.class;		}		synchronized(lock) {			URLStreamHandlerFactory orig = (URLStreamHandlerFactory) factoryField.get(null);			// doing a null check here just in case, but it would be really strange if it was null, 			// because we failed to set the factory normally!!			if (orig != null && orig.getClass().getName().equals(StreamHandlerFactory.class.getName()))				throw new Error("Multiple URLStreamHandlerFactories not supported."); //$NON-NLS-1$			// null out the field so that we can successfully call setURLStreamHandlerFactory			factoryField.set(null, null);			shf.setParentFactory(orig);			URL.setURLStreamHandlerFactory(shf);		}	}