Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2008-09-08 20:15:58 +0000
committerThomas Watson2008-09-08 20:15:58 +0000
commitdd9f2ba96a464ada6356684acaf1c0821cd64594 (patch)
tree1b7d22726cec68b382cffeb3aa92ec28b2435a6a
parent6c7c7c4b6ce28fa897cbd1f0803ce3bbce01939c (diff)
downloadrt.equinox.framework-dd9f2ba96a464ada6356684acaf1c0821cd64594.tar.gz
rt.equinox.framework-dd9f2ba96a464ada6356684acaf1c0821cd64594.tar.xz
rt.equinox.framework-dd9f2ba96a464ada6356684acaf1c0821cd64594.zip
Bug 245678 inconsistent security checkes for bundles with attached fragmentsv20080908-1645
-rw-r--r--bundles/org.eclipse.osgi.tests/.classpath2
-rw-r--r--bundles/org.eclipse.osgi.tests/build.properties8
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/META-INF/MANIFEST.MF6
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/resources/HostManifest_en_US.properties1
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/resources/frag.a.txt1
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/security.a/META-INF/MANIFEST.MF8
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/security.a/resources/HostManifest.properties1
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/security.a/security/a/Activator.java25
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/AllSecurityAdminTests.java1
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityManagerTests.java224
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java12
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java4
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java4
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ManifestLocalization.java13
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java13
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/SystemBundleLoader.java5
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/EquinoxFWClassLoader.java2
17 files changed, 302 insertions, 28 deletions
diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath
index 7cad8f6ef..7da2403f3 100644
--- a/bundles/org.eclipse.osgi.tests/.classpath
+++ b/bundles/org.eclipse.osgi.tests/.classpath
@@ -78,6 +78,8 @@
<classpathentry kind="src" output="bundle_tests/activator.error2" path="bundles_src/activator.error2"/>
<classpathentry kind="src" output="bundle_tests/activator.error3" path="bundles_src/activator.error3"/>
<classpathentry kind="src" output="bundle_tests/activator.error4" path="bundles_src/activator.error4"/>
+ <classpathentry kind="src" output="bundle_tests/security.a" path="bundles_src/security.a"/>
+ <classpathentry kind="src" output="bundle_tests/security.a.frag.a" path="bundles_src/security.a.frag.a"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties
index 50b5413fd..53fc7a0e4 100644
--- a/bundles/org.eclipse.osgi.tests/build.properties
+++ b/bundles/org.eclipse.osgi.tests/build.properties
@@ -171,6 +171,10 @@ source.bundle_tests/activator.error3.jar = bundles_src/activator.error3/
manifest.bundle_tests/activator.error3.jar = META-INF/MANIFEST.MF
source.bundle_tests/activator.error4.jar = bundles_src/activator.error4/
manifest.bundle_tests/activator.error4.jar = META-INF/MANIFEST.MF
+source.bundle_tests/security.a.jar = bundles_src/security.a/
+manifest.bundle_tests/security.a.jar = META-INF/MANIFEST.MF
+source.bundle_tests/security.a.frag.a.jar = bundles_src/security.a.frag.a/
+manifest.bundle_tests/security.a.frag.a.jar = META-INF/MANIFEST.MF
jars.compile.order = bundle_tests/ext.framework.b.jar,\
osgitests.jar,\
@@ -249,4 +253,6 @@ jars.compile.order = bundle_tests/ext.framework.b.jar,\
bundle_tests/activator.error1,\
bundle_tests/activator.error2,\
bundle_tests/activator.error3,\
- bundle_tests/activator.error4
+ bundle_tests/activator.error4,\
+ bundle_tests/security.a.jar,\
+ bundle_tests/security.a.frag.a.jar
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..737ea011e
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/META-INF/MANIFEST.MF
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: security.a.frag.a
+Bundle-SymbolicName: security.a.frag.a
+Fragment-Host: security.a
+Bundle-Version: 1.0.0
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/resources/HostManifest_en_US.properties b/bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/resources/HostManifest_en_US.properties
new file mode 100644
index 000000000..e00317dc1
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/resources/HostManifest_en_US.properties
@@ -0,0 +1 @@
+security.a=en_US
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/resources/frag.a.txt b/bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/resources/frag.a.txt
new file mode 100644
index 000000000..854152b47
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/security.a.frag.a/resources/frag.a.txt
@@ -0,0 +1 @@
+security.a.frag.a
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/security.a/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/security.a/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..b2f066f5a
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/security.a/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %security.a
+Bundle-SymbolicName: security.a
+Bundle-Version: 1.0.0
+Import-Package: org.osgi.framework
+Bundle-Activator: security.a.Activator
+Bundle-Localization: resources/HostManifest \ No newline at end of file
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/security.a/resources/HostManifest.properties b/bundles/org.eclipse.osgi.tests/bundles_src/security.a/resources/HostManifest.properties
new file mode 100644
index 000000000..43c11c1cc
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/security.a/resources/HostManifest.properties
@@ -0,0 +1 @@
+security.a=default
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/security.a/security/a/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/security.a/security/a/Activator.java
new file mode 100644
index 000000000..d3fd3bf81
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/security.a/security/a/Activator.java
@@ -0,0 +1,25 @@
+package security.a;
+
+import java.net.URL;
+import java.util.Enumeration;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ public void start(BundleContext context) throws Exception {
+ Enumeration urls = context.getBundle().findEntries("resources", "frag.a.txt", false); //$NON-NLS-1$//$NON-NLS-2$
+ if (urls == null || !urls.hasMoreElements())
+ throw new Exception("Did not find any resources"); //$NON-NLS-1$
+ while (urls.hasMoreElements()) {
+ URL url = (URL) urls.nextElement();
+ if (url == null)
+ throw new Exception("The URL is null"); //$NON-NLS-1$
+ }
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ //nothing
+ }
+
+}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/AllSecurityAdminTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/AllSecurityAdminTests.java
index 3eacf2784..bbf56d9ba 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/AllSecurityAdminTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/AllSecurityAdminTests.java
@@ -17,6 +17,7 @@ public class AllSecurityAdminTests {
public static Test suite() {
TestSuite suite = new TestSuite(AllSecurityAdminTests.class.getName());
suite.addTest(SecurityAdminUnitTests.suite());
+ suite.addTest(SecurityManagerTests.suite());
return suite;
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityManagerTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityManagerTests.java
new file mode 100644
index 000000000..d14df47b1
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityManagerTests.java
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.tests.securityadmin;
+
+import java.io.File;
+import java.security.*;
+import java.util.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.eclipse.osgi.framework.internal.core.Framework;
+import org.eclipse.osgi.launch.Equinox;
+import org.eclipse.osgi.tests.OSGiTestsActivator;
+import org.eclipse.osgi.tests.bundles.AbstractBundleTests;
+import org.osgi.framework.*;
+import org.osgi.framework.launch.SystemBundle;
+import org.osgi.service.condpermadmin.*;
+import org.osgi.service.permissionadmin.PermissionInfo;
+
+public class SecurityManagerTests extends AbstractBundleTests {
+ private static final PermissionInfo hostFragmentPermission = new PermissionInfo(BundlePermission.class.getName(), "*", "host,fragment"); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final PermissionInfo allPackagePermission = new PermissionInfo(PackagePermission.class.getName(), "*", "import,export"); //$NON-NLS-1$ //$NON-NLS-2$
+ private Policy previousPolicy;
+
+ public static Test suite() {
+ return new TestSuite(SecurityManagerTests.class);
+ }
+
+ protected void setUp() throws Exception {
+ if (System.getSecurityManager() != null)
+ fail("Cannot test with security manager set"); //$NON-NLS-1$
+ previousPolicy = Policy.getPolicy();
+ final Permission allPermission = new AllPermission();
+ final PermissionCollection allPermissions = new PermissionCollection() {
+ private static final long serialVersionUID = 3258131349494708277L;
+
+ // A simple PermissionCollection that only has AllPermission
+ public void add(Permission permission) {
+ //no adding to this policy
+ }
+
+ public boolean implies(Permission permission) {
+ return true;
+ }
+
+ public Enumeration elements() {
+ return new Enumeration() {
+ int cur = 0;
+
+ public boolean hasMoreElements() {
+ return cur < 1;
+ }
+
+ public Object nextElement() {
+ if (cur == 0) {
+ cur = 1;
+ return allPermission;
+ }
+ throw new NoSuchElementException();
+ }
+ };
+ }
+ };
+
+ Policy.setPolicy(new Policy() {
+
+ public PermissionCollection getPermissions(CodeSource codesource) {
+ return allPermissions;
+ }
+
+ public void refresh() {
+ // nothing
+ }
+
+ });
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if (System.getSecurityManager() != null)
+ System.setSecurityManager(null);
+ Policy.setPolicy(previousPolicy);
+ }
+
+ public void testEnableSecurityManager01() {
+ File config = OSGiTestsActivator.getContext().getDataFile("testEnableSecurityManager01"); //$NON-NLS-1$
+ Properties configuration = new Properties();
+ configuration.put(SystemBundle.STORAGE, config.getAbsolutePath());
+ configuration.put(Framework.PROP_EQUINOX_SECURITY, Framework.SECURITY_OSGI);
+ Equinox equinox = new Equinox();
+ equinox.init(configuration);
+ assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
+ // should be in the STARTING state
+ assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$
+ try {
+ equinox.start();
+ } catch (BundleException e) {
+ fail("Failed to start the framework", e); //$NON-NLS-1$
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState()); //$NON-NLS-1$
+ // put the framework back to the RESOLVED state
+ try {
+ equinox.stop();
+ } catch (BundleException e) {
+ fail("Unexpected erorr stopping framework", e); //$NON-NLS-1$
+ }
+ try {
+ equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ fail("Unexpected interrupted exception", e); //$NON-NLS-1$
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
+ assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
+ }
+
+ public void testEnableSecurityManager02() throws BundleException {
+ // create/start/stop/start/stop test
+ File config = OSGiTestsActivator.getContext().getDataFile("testEnableSecurityManager02"); //$NON-NLS-1$
+ Properties configuration = new Properties();
+ configuration.put(SystemBundle.STORAGE, config.getAbsolutePath());
+ configuration.put(Framework.PROP_EQUINOX_SECURITY, Framework.SECURITY_OSGI);
+ Equinox equinox = new Equinox();
+ equinox.init(configuration);
+ assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
+ // should be in the STARTING state
+ assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$
+
+ BundleContext systemContext = equinox.getBundleContext();
+ assertNotNull("System context is null", systemContext); //$NON-NLS-1$
+ // try installing host and fragment to test bug 245678
+ String locationSecurityA = installer.getBundleLocation("security.a"); //$NON-NLS-1$
+ String locationSecurityAFragA = installer.getBundleLocation("security.a.frag.a"); //$NON-NLS-1$
+ // set the security for the host and fragment
+ ConditionalPermissionAdmin ca = (ConditionalPermissionAdmin) systemContext.getService(systemContext.getServiceReference(ConditionalPermissionAdmin.class.getName()));
+ ConditionalPermissionsUpdate update = ca.createConditionalPermissionsUpdate();
+ List rows = update.getConditionalPermissionInfoBases();
+ rows.add(ca.createConditionalPermissionInfoBase(null, null, new PermissionInfo[] {hostFragmentPermission, allPackagePermission}, ConditionalPermissionInfoBase.ALLOW));
+ assertTrue("Cannot commit rows", update.commit()); //$NON-NLS-1$
+
+ Bundle securityA = systemContext.installBundle(locationSecurityA);
+ systemContext.installBundle(locationSecurityAFragA);
+
+ equinox.start();
+
+ try {
+ securityA.start();
+ } catch (BundleException e) {
+ fail("Failed to start securityA", e); //$NON-NLS-1$
+ } finally {
+ // put the framework back to the RESOLVED state
+ equinox.stop();
+
+ try {
+ equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ fail("Unexpected interrupted exception", e); //$NON-NLS-1$
+ }
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
+ assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
+ }
+
+ public void testLocalization01() throws BundleException {
+ // create/start/stop/start/stop test
+ File config = OSGiTestsActivator.getContext().getDataFile("testLocalization01"); //$NON-NLS-1$
+ Properties configuration = new Properties();
+ configuration.put(SystemBundle.STORAGE, config.getAbsolutePath());
+ configuration.put(Framework.PROP_EQUINOX_SECURITY, Framework.SECURITY_OSGI);
+ Equinox equinox = new Equinox();
+ equinox.init(configuration);
+ assertNotNull("SecurityManager is null", System.getSecurityManager()); //$NON-NLS-1$
+ // should be in the STARTING state
+ assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$
+
+ BundleContext systemContext = equinox.getBundleContext();
+ assertNotNull("System context is null", systemContext); //$NON-NLS-1$
+ // try installing host and fragment to test bug 245678
+ String locationSecurityA = installer.getBundleLocation("security.a"); //$NON-NLS-1$
+ String locationSecurityAFragA = installer.getBundleLocation("security.a.frag.a"); //$NON-NLS-1$
+ // set the security for the host and fragment
+ ConditionalPermissionAdmin ca = (ConditionalPermissionAdmin) systemContext.getService(systemContext.getServiceReference(ConditionalPermissionAdmin.class.getName()));
+ ConditionalPermissionsUpdate update = ca.createConditionalPermissionsUpdate();
+ List rows = update.getConditionalPermissionInfoBases();
+ rows.add(ca.createConditionalPermissionInfoBase(null, null, new PermissionInfo[] {hostFragmentPermission, allPackagePermission}, ConditionalPermissionInfoBase.ALLOW));
+ assertTrue("Cannot commit rows", update.commit()); //$NON-NLS-1$
+
+ Bundle securityA = systemContext.installBundle(locationSecurityA);
+ systemContext.installBundle(locationSecurityAFragA);
+
+ equinox.start();
+
+ try {
+ securityA.start();
+ Dictionary headers = securityA.getHeaders("en_US"); //$NON-NLS-1$
+ String name = (String) headers.get(Constants.BUNDLE_NAME);
+ assertEquals("Wrong Bundle-Name", "en_US", name); //$NON-NLS-1$ //$NON-NLS-2$
+
+ headers = securityA.getHeaders("en"); //$NON-NLS-1$
+ name = (String) headers.get(Constants.BUNDLE_NAME);
+ assertEquals("Wrong Bundle-Name", "default", name); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (BundleException e) {
+ fail("Failed to start securityA", e); //$NON-NLS-1$
+ } finally {
+ // put the framework back to the RESOLVED state
+ equinox.stop();
+
+ try {
+ equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ fail("Unexpected interrupted exception", e); //$NON-NLS-1$
+ }
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
+ assertNull("SecurityManager is not null", System.getSecurityManager()); //$NON-NLS-1$
+ }
+}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java
index debc84769..fa5fdaaa3 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java
@@ -1245,7 +1245,7 @@ public abstract class AbstractBundle implements Bundle, Comparable, KeyedElement
return domain;
}
- protected Bundle[] getFragments() {
+ protected BundleFragment[] getFragments() {
checkValid();
return null;
}
@@ -1299,6 +1299,10 @@ public abstract class AbstractBundle implements Bundle, Comparable, KeyedElement
} catch (SecurityException e) {
return null;
}
+ return getEntry0(fileName);
+ }
+
+ URL getEntry0(String fileName) {
checkValid();
if (System.getSecurityManager() == null)
return bundledata.getEntry(fileName);
@@ -1467,7 +1471,7 @@ public abstract class AbstractBundle implements Bundle, Comparable, KeyedElement
// find the local entries of this bundle
findLocalEntryPaths(path, patternFilter, patternProps, recurse, pathList);
// if this bundle is a host to fragments then search the fragments
- final Bundle[] fragments = getFragments();
+ final BundleFragment[] fragments = getFragments();
final int numFragments = fragments == null ? -1 : fragments.length;
for (int i = 0; i < numFragments; i++)
((AbstractBundle) fragments[i]).findLocalEntryPaths(path, patternFilter, patternProps, recurse, pathList);
@@ -1506,12 +1510,12 @@ public abstract class AbstractBundle implements Bundle, Comparable, KeyedElement
String curPath = pathArray[curIndex];
if (curFragment == -1) {
// need to search ourselves first
- nextElement = getEntry(curPath);
+ nextElement = getEntry0(curPath);
curFragment++;
}
// if the element is not in the host look in the fragments until we have searched them all
while (nextElement == null && curFragment < numFragments)
- nextElement = fragments[curFragment++].getEntry(curPath);
+ nextElement = fragments[curFragment++].getEntry0(curPath);
// if we have no fragments or we have searched all fragments then advance to the next path
if (numFragments == -1 || curFragment >= numFragments) {
curIndex++;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
index b83723e7c..190fd3712 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
@@ -531,11 +531,11 @@ public class BundleHost extends AbstractBundle {
return context.getFramework().getServiceRegistry().getServicesInUse(context);
}
- public Bundle[] getFragments() {
+ public BundleFragment[] getFragments() {
synchronized (framework.bundles) {
if (fragments == null)
return null;
- Bundle[] result = new Bundle[fragments.length];
+ BundleFragment[] result = new BundleFragment[fragments.length];
System.arraycopy(fragments, 0, result, 0, result.length);
return result;
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
index beee5a766..779dac5a8 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
@@ -551,7 +551,7 @@ public class Framework implements EventDispatcher, EventPublisher, Runnable {
}
private URL findInSystemBundle(String entry) {
- URL result = systemBundle.getEntry(entry);
+ URL result = systemBundle.getEntry0(entry);
if (result == null) {
// Check the ClassLoader in case we're launched off the Java boot classpath
ClassLoader loader = getClass().getClassLoader();
@@ -611,6 +611,8 @@ public class Framework implements EventDispatcher, EventPublisher, Runnable {
adaptor = null;
uninstallURLStreamHandlerFactory();
uninstallContentHandlerFactory();
+ if (System.getSecurityManager() instanceof EquinoxSecurityManager)
+ System.setSecurityManager(null);
}
/**
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ManifestLocalization.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ManifestLocalization.java
index 825ae8d94..d0067fd2c 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ManifestLocalization.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ManifestLocalization.java
@@ -148,27 +148,22 @@ public class ManifestLocalization {
}
return findInResolved(resource, searchBundle);
}
- return findInBundle(resource, searchBundle);
+ return searchBundle.getEntry0(resource);
}
private URL findInResolved(String filePath, AbstractBundle bundleHost) {
-
- URL result = findInBundle(filePath, bundleHost);
+ URL result = bundleHost.getEntry0(filePath);
if (result != null)
return result;
return findInFragments(filePath, bundleHost);
}
- private URL findInBundle(String filePath, AbstractBundle searchBundle) {
- return searchBundle.getEntry(filePath);
- }
-
private URL findInFragments(String filePath, AbstractBundle searchBundle) {
- org.osgi.framework.Bundle[] fragments = searchBundle.getFragments();
+ BundleFragment[] fragments = searchBundle.getFragments();
URL fileURL = null;
for (int i = 0; fragments != null && i < fragments.length && fileURL == null; i++) {
if (fragments[i].getState() != Bundle.UNINSTALLED)
- fileURL = fragments[i].getEntry(filePath);
+ fileURL = fragments[i].getEntry0(filePath);
}
return fileURL;
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java
index 126ba9941..045a91e3b 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java
@@ -205,10 +205,10 @@ public class BundleLoader implements ClassLoaderDelegate {
}
//This is the fastest way to access to the description for fragments since the hostdescription.getFragments() is slow
- org.osgi.framework.Bundle[] fragmentObjects = bundle.getFragments();
+ BundleFragment[] fragmentObjects = bundle.getFragments();
BundleDescription[] fragments = new BundleDescription[fragmentObjects == null ? 0 : fragmentObjects.length];
for (int i = 0; i < fragments.length; i++)
- fragments[i] = ((AbstractBundle) fragmentObjects[i]).getBundleDescription();
+ fragments[i] = fragmentObjects[i].getBundleDescription();
// init the dynamic imports tables
if (description.hasDynamicImports())
addDynamicImportPackage(description.getImportPackages());
@@ -780,10 +780,10 @@ public class BundleLoader implements ClassLoaderDelegate {
return result;
// look in fragments imports ...
- org.osgi.framework.Bundle[] fragments = bundle.getFragments();
+ BundleFragment[] fragments = bundle.getFragments();
if (fragments != null)
for (int i = 0; i < fragments.length; i++) {
- result = ((AbstractBundle) fragments[i]).getBundleData().findLibrary(name);
+ result = fragments[i].getBundleData().findLibrary(name);
if (result != null)
return result;
}
@@ -820,12 +820,11 @@ public class BundleLoader implements ClassLoaderDelegate {
BundleClassLoader createBCL(final BundleProtectionDomain pd, final String[] cp) {
BundleClassLoader bcl = bundle.getBundleData().createClassLoader(BundleLoader.this, pd, cp);
// attach existing fragments to classloader
- org.osgi.framework.Bundle[] fragments = bundle.getFragments();
+ BundleFragment[] fragments = bundle.getFragments();
if (fragments != null)
for (int i = 0; i < fragments.length; i++) {
- AbstractBundle fragment = (AbstractBundle) fragments[i];
try {
- bcl.attachFragment(fragment.getBundleData(), fragment.getProtectionDomain(), fragment.getBundleData().getClassPath());
+ bcl.attachFragment(fragments[i].getBundleData(), fragments[i].getProtectionDomain(), fragments[i].getBundleData().getClassPath());
} catch (BundleException be) {
bundle.getFramework().publishFrameworkEvent(FrameworkEvent.ERROR, bundle, be);
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/SystemBundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/SystemBundleLoader.java
index b45d4a1bc..4968454cd 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/SystemBundleLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/SystemBundleLoader.java
@@ -19,7 +19,6 @@ import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.internal.core.BundleFragment;
import org.eclipse.osgi.framework.internal.core.BundleHost;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
/**
@@ -51,10 +50,10 @@ public class SystemBundleLoader extends BundleLoader {
}
this.classLoader = getClass().getClassLoader();
extPackages = new HashSet(0); // not common; start with 0
- Bundle[] fragments = bundle.getFragments();
+ BundleFragment[] fragments = bundle.getFragments();
if (fragments != null)
for (int i = 0; i < fragments.length; i++)
- addExtPackages((BundleFragment) fragments[i]);
+ addExtPackages(fragments[i]);
ClassLoader extCL = ClassLoader.getSystemClassLoader();
if (extCL == null)
extClassLoader = null;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/EquinoxFWClassLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/EquinoxFWClassLoader.java
index 8a612795f..90604d5ad 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/EquinoxFWClassLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/launch/EquinoxFWClassLoader.java
@@ -15,7 +15,7 @@ import java.net.URLClassLoader;
class EquinoxFWClassLoader extends URLClassLoader {
- private static final String[] DELEGATE_PARENT = {"org.osgi.", "org.eclipse.osgi.launch.", "org.eclipse.osgi.service."}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final String[] DELEGATE_PARENT = {"java.", "org.osgi.", "org.eclipse.osgi.launch.", "org.eclipse.osgi.service."}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
private static final String[] SKIP_PARENT = {"org.osgi.framework.AdminPermission", "org.osgi.framework.FrameworkUtil", "org.osgi.service.condpermadmin.BundleSignerCondition"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private final ClassLoader parent;

Back to the top