Bug 574807 - force FrameworkUtil to clinit before we register
Forcing FrameworkUtil to clinit before we register our factory with the
multiplex factory allows it to successfully clinit before we have any
chance of using it as part of our factory implementation.
Change-Id: Ia1c3d9e54b1b9cf143b40121ef2f53fd0e012fe8
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/183002
Tested-by: Equinox Bot <equinox-bot@eclipse.org>
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/EquinoxFactoryManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/EquinoxFactoryManager.java
index 7c55f0e..677d96d 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/EquinoxFactoryManager.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/EquinoxFactoryManager.java
@@ -19,10 +19,12 @@
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandlerFactory;
+import java.util.Collections;
import java.util.Hashtable;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.internal.framework.EquinoxContainer;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
public class EquinoxFactoryManager {
private final EquinoxContainer container;
@@ -58,6 +60,9 @@
}
private static void forceURLStreamHandlerFactory(URLStreamHandlerFactoryImpl shf) throws Exception {
+ // force our FrameworkUtil to initialize before we register to avoid calling
+ // getBundle before we register this as a multiplexing handler
+ FrameworkUtil.asDictionary(Collections.emptyMap());
Field factoryField = getField(URL.class, URLStreamHandlerFactory.class, false);
if (factoryField == null)
throw new Exception("Could not find URLStreamHandlerFactory field"); //$NON-NLS-1$