private static void forceURLStreamHandlerFactory(URLStreamHandlerFactoryImpl shf) throws Exception { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) throw new Exception("Could not find URLStreamHandlerFactory field"); //$NON-NLS-1$ // look for a lock to synchronize on Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (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 (factory != null) { try { factory.getClass().getMethod("isMultiplexing", (Class[]) null); //$NON-NLS-1$ Method register = factory.getClass().getMethod("register", new Class[] {Object.class}); //$NON-NLS-1$ register.invoke(factory, new Object[] {shf}); } catch (NoSuchMethodException e) { // current factory does not support multiplexing, ok we'll wrap it shf.setParentFactory(factory); factory = shf; } } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optomization for the single framework use-case resetURLStreamHandlers(); URL.setURLStreamHandlerFactory(factory); } }
private static void forceURLStreamHandlerFactory(URLStreamHandlerFactoryImpl shf) throws Exception { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) throw new Exception("Could not find URLStreamHandlerFactory field"); //$NON-NLS-1$ // look for a lock to synchronize on Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (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 (factory != null) { try { factory.getClass().getMethod("isMultiplexing", (Class[]) null); //$NON-NLS-1$ Method register = factory.getClass().getMethod("register", new Class[] {Object.class}); //$NON-NLS-1$ register.invoke(factory, new Object[] {shf}); } catch (NoSuchMethodException e) { // current factory does not support multiplexing, ok we'll wrap it shf.setParentFactory(factory); factory = shf; } } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optomization for the single framework use-case resetURLStreamHandlers(); URL.setURLStreamHandlerFactory(factory); } }
private static void forceURLStreamHandlerFactory(URLStreamHandlerFactoryImpl shf) throws Exception { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) throw new Exception("Could not find URLStreamHandlerFactory field"); //$NON-NLS-1$ // look for a lock to synchronize on Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (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 (factory != null) { try { factory.getClass().getMethod("isMultiplexing", (Class[]) null); //$NON-NLS-1$ Method register = factory.getClass().getMethod("register", new Class[] {Object.class}); //$NON-NLS-1$ register.invoke(factory, new Object[] {shf}); } catch (NoSuchMethodException e) { // current factory does not support multiplexing, ok we'll wrap it shf.setParentFactory(factory); factory = shf; } } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optomization for the single framework use-case resetURLStreamHandlers(); URL.setURLStreamHandlerFactory(factory); } }
private static void forceURLStreamHandlerFactory(URLStreamHandlerFactoryImpl shf) throws Exception { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) throw new Exception("Could not find URLStreamHandlerFactory field"); //$NON-NLS-1$ // look for a lock to synchronize on Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (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 (factory != null) { try { factory.getClass().getMethod("isMultiplexing", (Class[]) null); //$NON-NLS-1$ Method register = factory.getClass().getMethod("register", new Class[] {Object.class}); //$NON-NLS-1$ register.invoke(factory, new Object[] {shf}); } catch (NoSuchMethodException e) { // current factory does not support multiplexing, ok we'll wrap it shf.setParentFactory(factory); factory = shf; } } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optomization for the single framework use-case resetURLStreamHandlers(); URL.setURLStreamHandlerFactory(factory); } }
private static void forceURLStreamHandlerFactory(URLStreamHandlerFactoryImpl shf) throws Exception { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) throw new Exception("Could not find URLStreamHandlerFactory field"); //$NON-NLS-1$ // look for a lock to synchronize on Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (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 (factory != null) { try { factory.getClass().getMethod("isMultiplexing", (Class[]) null); //$NON-NLS-1$ Method register = factory.getClass().getMethod("register", new Class[] {Object.class}); //$NON-NLS-1$ register.invoke(factory, new Object[] {shf}); } catch (NoSuchMethodException e) { // current factory does not support multiplexing, ok we'll wrap it shf.setParentFactory(factory); factory = shf; } } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optomization for the single framework use-case resetURLStreamHandlers(); URL.setURLStreamHandlerFactory(factory); } }
private static void forceURLStreamHandlerFactory(URLStreamHandlerFactoryImpl shf) throws Exception { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) throw new Exception("Could not find URLStreamHandlerFactory field"); //$NON-NLS-1$ // look for a lock to synchronize on Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (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 (factory != null) { try { factory.getClass().getMethod("isMultiplexing", (Class[]) null); //$NON-NLS-1$ Method register = factory.getClass().getMethod("register", new Class[] {Object.class}); //$NON-NLS-1$ register.invoke(factory, new Object[] {shf}); } catch (NoSuchMethodException e) { // current factory does not support multiplexing, ok we'll wrap it shf.setParentFactory(factory); factory = shf; } } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optomization for the single framework use-case resetURLStreamHandlers(); URL.setURLStreamHandlerFactory(factory); } }
private void uninstallURLStreamHandlerFactory() { try { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) return; // oh well, we tried Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (URLStreamHandlerFactory) factoryField.get(null); if (factory == urlStreamHandlerFactory) { factory = (URLStreamHandlerFactory) urlStreamHandlerFactory.designateSuccessor(); } else { Method unregister = factory.getClass().getMethod("unregister", new Class[] {Object.class}); //$NON-NLS-1$ unregister.invoke(factory, new Object[] {urlStreamHandlerFactory}); } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optimization for the single framework use-case // Note that the call to setURLStreamHandlerFactory below may clear this cache // but we want to be sure to clear it here just in case the parent is null. // In this case the call below would not occur. resetURLStreamHandlers(); if (factory != null) URL.setURLStreamHandlerFactory(factory); } } catch (Exception e) { // ignore and continue closing the framework } }
private void uninstallURLStreamHandlerFactory() { try { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) return; // oh well, we tried Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (URLStreamHandlerFactory) factoryField.get(null); if (factory == urlStreamHandlerFactory) { factory = (URLStreamHandlerFactory) urlStreamHandlerFactory.designateSuccessor(); } else { Method unregister = factory.getClass().getMethod("unregister", new Class[] {Object.class}); //$NON-NLS-1$ unregister.invoke(factory, new Object[] {urlStreamHandlerFactory}); } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optimization for the single framework use-case // Note that the call to setURLStreamHandlerFactory below may clear this cache // but we want to be sure to clear it here just in case the parent is null. // In this case the call below would not occur. resetURLStreamHandlers(); if (factory != null) URL.setURLStreamHandlerFactory(factory); } } catch (Exception e) { // ignore and continue closing the framework } }
private void uninstallURLStreamHandlerFactory() { try { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) return; // oh well, we tried Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (URLStreamHandlerFactory) factoryField.get(null); if (factory == urlStreamHandlerFactory) { factory = (URLStreamHandlerFactory) urlStreamHandlerFactory.designateSuccessor(); } else { Method unregister = factory.getClass().getMethod("unregister", new Class[] {Object.class}); //$NON-NLS-1$ unregister.invoke(factory, new Object[] {urlStreamHandlerFactory}); } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optimization for the single framework use-case // Note that the call to setURLStreamHandlerFactory below may clear this cache // but we want to be sure to clear it here just in case the parent is null. // In this case the call below would not occur. resetURLStreamHandlers(); if (factory != null) URL.setURLStreamHandlerFactory(factory); } } catch (Exception e) { // ignore and continue closing the framework } }
private void uninstallURLStreamHandlerFactory() { try { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) return; // oh well, we tried Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (URLStreamHandlerFactory) factoryField.get(null); if (factory == urlStreamHandlerFactory) { factory = (URLStreamHandlerFactory) urlStreamHandlerFactory.designateSuccessor(); } else { Method unregister = factory.getClass().getMethod("unregister", new Class[] {Object.class}); //$NON-NLS-1$ unregister.invoke(factory, new Object[] {urlStreamHandlerFactory}); } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optimization for the single framework use-case // Note that the call to setURLStreamHandlerFactory below may clear this cache // but we want to be sure to clear it here just in case the parent is null. // In this case the call below would not occur. resetURLStreamHandlers(); if (factory != null) URL.setURLStreamHandlerFactory(factory); } } catch (Exception e) { // ignore and continue closing the framework } }
private void uninstallURLStreamHandlerFactory() { try { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) return; // oh well, we tried Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (URLStreamHandlerFactory) factoryField.get(null); if (factory == urlStreamHandlerFactory) { factory = (URLStreamHandlerFactory) urlStreamHandlerFactory.designateSuccessor(); } else { Method unregister = factory.getClass().getMethod("unregister", new Class[] {Object.class}); //$NON-NLS-1$ unregister.invoke(factory, new Object[] {urlStreamHandlerFactory}); } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optimization for the single framework use-case // Note that the call to setURLStreamHandlerFactory below may clear this cache // but we want to be sure to clear it here just in case the parent is null. // In this case the call below would not occur. resetURLStreamHandlers(); if (factory != null) URL.setURLStreamHandlerFactory(factory); } } catch (Exception e) { // ignore and continue closing the framework } }
private void uninstallURLStreamHandlerFactory() { try { Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false); if (factoryField == null) return; // oh well, we tried Object lock = getURLStreamHandlerFactoryLock(); synchronized (lock) { URLStreamHandlerFactory factory = (URLStreamHandlerFactory) factoryField.get(null); if (factory == urlStreamHandlerFactory) { factory = (URLStreamHandlerFactory) urlStreamHandlerFactory.designateSuccessor(); } else { Method unregister = factory.getClass().getMethod("unregister", new Class[] {Object.class}); //$NON-NLS-1$ unregister.invoke(factory, new Object[] {urlStreamHandlerFactory}); } factoryField.set(null, null); // always attempt to clear the handlers cache // This allows an optimization for the single framework use-case // Note that the call to setURLStreamHandlerFactory below may clear this cache // but we want to be sure to clear it here just in case the parent is null. // In this case the call below would not occur. resetURLStreamHandlers(); if (factory != null) URL.setURLStreamHandlerFactory(factory); } } catch (Exception e) { // ignore and continue closing the framework } }