diff options
author | Thomas Watson | 2013-11-13 20:23:33 +0000 |
---|---|---|
committer | Thomas Watson | 2013-11-13 21:08:38 +0000 |
commit | 02b3b24304b2669850104a8075ed540cc45f550a (patch) | |
tree | e4625bed6be627df75ff2b1ad164285cb362e2ee | |
parent | fa4981d7e3e2cf48a3c641c913dc259aeecd016f (diff) | |
download | rt.equinox.framework-02b3b24304b2669850104a8075ed540cc45f550a.tar.gz rt.equinox.framework-02b3b24304b2669850104a8075ed540cc45f550a.tar.xz rt.equinox.framework-02b3b24304b2669850104a8075ed540cc45f550a.zip |
Bug 421667 - Allow framework implementation to work on the boot class
path
3 files changed, 32 insertions, 11 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java index 1e21e24c1..143628121 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java @@ -25,6 +25,7 @@ import java.io.*; import java.lang.reflect.Method; import java.net.*; import java.security.CodeSource; +import java.security.ProtectionDomain; import java.util.*; import org.eclipse.core.runtime.internal.adaptor.ConsoleManager; import org.eclipse.osgi.internal.debug.Debug; @@ -602,10 +603,25 @@ public class EquinoxConfiguration implements EnvironmentInfo { private static void initializeProperties(Properties configuration, AliasMapper aliasMapper) { // initialize some framework properties that must always be set if (configuration.get(PROP_FRAMEWORK) == null || configuration.get(EquinoxLocations.PROP_INSTALL_AREA) == null) { - CodeSource cs = EquinoxConfiguration.class.getProtectionDomain().getCodeSource(); - if (cs == null) - throw new IllegalArgumentException(NLS.bind(Msg.ECLIPSE_STARTUP_PROPS_NOT_SET, PROP_FRAMEWORK + ", " + EquinoxLocations.PROP_INSTALL_AREA)); //$NON-NLS-1$ - URL url = cs.getLocation(); + ProtectionDomain pd = EquinoxConfiguration.class.getProtectionDomain(); + CodeSource cs = pd == null ? null : pd.getCodeSource(); + URL url = cs == null ? null : cs.getLocation(); + if (url == null) { + IOException cause = null; + // try to determine by loading a resource we know we have + URL java6Profile = EquinoxConfiguration.class.getResource("/JavaSE-1.6.profile"); //$NON-NLS-1$ + if (java6Profile != null && "jar".equals(java6Profile.getProtocol())) { //$NON-NLS-1$ + try { + url = ((JarURLConnection) java6Profile.openConnection()).getJarFileURL(); + } catch (IOException e) { + cause = e; + } + } + if (url == null) { + throw new IllegalArgumentException(NLS.bind(Msg.ECLIPSE_STARTUP_PROPS_NOT_SET, PROP_FRAMEWORK + ", " + EquinoxLocations.PROP_INSTALL_AREA), cause); //$NON-NLS-1$ + } + } + // allow props to be preset if (configuration.get(PROP_FRAMEWORK) == null) { String externalForm = getFrameworkPath(url.toExternalForm(), false); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java index 67c82a7ea..92538b4ae 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java @@ -26,6 +26,7 @@ import org.osgi.framework.hooks.resolver.ResolverHookFactory; import org.osgi.framework.wiring.BundleRevision; public class EquinoxContainerAdaptor extends ModuleContainerAdaptor { + private static final ClassLoader BOOT_CLASSLOADER = new ClassLoader(Object.class.getClassLoader()) { /* boot class loader */}; private final EquinoxContainer container; private final Storage storage; private final OSGiFrameworkHooks hooks; @@ -51,8 +52,10 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor { type = configuration.getConfiguration(EquinoxConfiguration.PROP_PARENT_CLASSLOADER, Constants.FRAMEWORK_BUNDLE_PARENT_BOOT); } - if (Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK.equalsIgnoreCase(type) || EquinoxConfiguration.PARENT_CLASSLOADER_FWK.equalsIgnoreCase(type)) - return EquinoxContainer.class.getClassLoader(); + if (Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK.equalsIgnoreCase(type) || EquinoxConfiguration.PARENT_CLASSLOADER_FWK.equalsIgnoreCase(type)) { + ClassLoader cl = EquinoxContainer.class.getClassLoader(); + return cl == null ? BOOT_CLASSLOADER : cl; + } if (Constants.FRAMEWORK_BUNDLE_PARENT_APP.equalsIgnoreCase(type)) return ClassLoader.getSystemClassLoader(); if (Constants.FRAMEWORK_BUNDLE_PARENT_EXT.equalsIgnoreCase(type)) { @@ -60,7 +63,7 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor { if (appCL != null) return appCL.getParent(); } - return new ClassLoader(Object.class.getClassLoader()) {/* boot class loader*/}; + return BOOT_CLASSLOADER; } @@ -109,7 +112,9 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor { @Override public ModuleLoader createModuleLoader(ModuleWiring wiring) { if (wiring.getBundle().getBundleId() == 0) { - return new SystemBundleLoader(wiring, container); + ClassLoader cl = EquinoxContainer.class.getClassLoader(); + cl = cl == null ? BOOT_CLASSLOADER : cl; + return new SystemBundleLoader(wiring, container, cl); } if ((wiring.getRevision().getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) { return new FragmentLoader(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/SystemBundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/SystemBundleLoader.java index 2d984cd46..c79f4cda1 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/SystemBundleLoader.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/SystemBundleLoader.java @@ -31,9 +31,9 @@ public class SystemBundleLoader extends BundleLoader { final ClassLoader classLoader; final ModuleClassLoader moduleClassLoader; - public SystemBundleLoader(ModuleWiring wiring, EquinoxContainer container) { - super(wiring, container, SystemBundleLoader.class.getClassLoader().getParent()); - this.classLoader = getClass().getClassLoader(); + public SystemBundleLoader(ModuleWiring wiring, EquinoxContainer container, ClassLoader frameworkLoader) { + super(wiring, container, frameworkLoader.getParent()); + this.classLoader = frameworkLoader; this.moduleClassLoader = new SystemModuleClassLoader(classLoader.getParent(), container.getConfiguration(), this, (Generation) wiring.getRevision().getRevisionInfo()); } |