Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2015-08-11 15:32:36 +0000
committerThomas Watson2015-08-11 15:32:36 +0000
commit52896896aac837cb5d716383f38a6da44fd4796b (patch)
tree3676c6fea97c0ad3368e7b770a387698ec54db7f
parenta01aa517aa6aa58815d8db1b948db89611ca9dce (diff)
downloadrt.equinox.framework-52896896aac837cb5d716383f38a6da44fd4796b.tar.gz
rt.equinox.framework-52896896aac837cb5d716383f38a6da44fd4796b.tar.xz
rt.equinox.framework-52896896aac837cb5d716383f38a6da44fd4796b.zip
Bug 471551 - SchemaFactory - Loading behaves differently by switchingI20150811-1400
from java 7 to 8
-rw-r--r--bundles/org.eclipse.osgi.tests/.classpath3
-rw-r--r--bundles/org.eclipse.osgi.tests/.settings/org.eclipse.core.runtime.prefs2
-rw-r--r--bundles/org.eclipse.osgi.tests/build.properties5
-rwxr-xr-xbundles/org.eclipse.osgi.tests/bundles_src/test.bug471551/META-INF/MANIFEST.MF8
-rwxr-xr-xbundles/org.eclipse.osgi.tests/bundles_src/test.bug471551/test/bug471551/Activator.java39
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java19
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java12
7 files changed, 79 insertions, 9 deletions
diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath
index aa1bad3a2..c4bb1a508 100644
--- a/bundles/org.eclipse.osgi.tests/.classpath
+++ b/bundles/org.eclipse.osgi.tests/.classpath
@@ -128,8 +128,9 @@
<classpathentry kind="src" output="bundle_tests/test.bug438904.frag" path="bundles_src/test.bug438904.frag"/>
<classpathentry kind="src" output="bundle_tests/test.bug438904.global" path="bundles_src/test.bug438904.global"/>
<classpathentry kind="src" output="bundle_tests/test.system.nls" path="bundles_src/test.system.nls"/>
- <classpathentry kind="src" output="bundle_tests/test.bug449484" path="bundles_src/test.bug449484"/>
+ <classpathentry kind="src" output="bundle_tests/test.bug449484" path="bundles_src/test.bug449484"/>
<classpathentry kind="src" output="bundle_tests/wrapper.hooks.a" path="bundles_src/wrapper.hooks.a"/>
<classpathentry kind="src" output="bundle_tests/test.protocol.handler" path="bundles_src/test.protocol.handler"/>
+ <classpathentry kind="src" output="bundle_tests/test.bug471551" path="bundles_src/test.bug471551"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bundles/org.eclipse.osgi.tests/.settings/org.eclipse.core.runtime.prefs b/bundles/org.eclipse.osgi.tests/.settings/org.eclipse.core.runtime.prefs
new file mode 100644
index 000000000..5a0ad22d2
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties
index e654843ba..899fea372 100644
--- a/bundles/org.eclipse.osgi.tests/build.properties
+++ b/bundles/org.eclipse.osgi.tests/build.properties
@@ -266,6 +266,8 @@ source.bundle_tests/wrapper.hooks.a.jar = bundles_src/wrapper.hooks.a/
manifest.bundle_tests/wrapper.hooks.a.jar = META-INF/MANIFEST.MF
source.bundle_tests/test.protocol.handler.jar = bundles_src/test.protocol.handler/
manifest.bundle_tests/test.protocol.handler.jar = META-INF/MANIFEST.MF
+source.bundle_tests/test.bug471551.jar = bundles_src/test.bug471551/
+manifest.bundle_tests/test.bug471551.jar = META-INF/MANIFEST.MF
jars.compile.order = bundle_tests/ext.framework.b.jar,\
osgitests.jar,\
@@ -394,4 +396,5 @@ jars.compile.order = bundle_tests/ext.framework.b.jar,\
bundle_tests/test.system.nls.jar,\
bundle_tests/test.bug449484.jar,\
bundle_tests/wrapper.hooks.a.jar,\
- bundle_tests/test.protocol.handler.jar
+ bundle_tests/test.protocol.handler.jar,\
+ bundle_tests/test.bug471551.jar
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.bug471551/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug471551/META-INF/MANIFEST.MF
new file mode 100755
index 000000000..9280f6ce9
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug471551/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: test.bug471551
+Bundle-Version: 1.0
+Import-Package: org.osgi.framework,
+ org.osgi.framework.wiring,
+ javax.xml.validation
+Bundle-Activator: test.bug471551.Activator
+
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.bug471551/test/bug471551/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug471551/test/bug471551/Activator.java
new file mode 100755
index 000000000..eb5da92e1
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug471551/test/bug471551/Activator.java
@@ -0,0 +1,39 @@
+
+/*******************************************************************************
+ * Copyright (c) 2015 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 test.bug471551;
+
+import javax.xml.validation.SchemaFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.wiring.BundleWiring;
+
+public class Activator implements BundleActivator {
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ ClassLoader cl = context.getBundle().adapt(BundleWiring.class).getClassLoader();
+ ClassLoader currentTCCL = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+ try {
+ SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
+ System.out.println("SchemaFactory with TCCL: " + sf.getClass().getName());
+ } finally {
+ Thread.currentThread().setContextClassLoader(currentTCCL);
+ }
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ // nothing
+ }
+
+}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index 33cda2022..d624439b5 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -2447,6 +2447,25 @@ public class SystemBundleTests extends AbstractBundleTests {
equinox.stop();
}
+ public void testContextBootDelegation() throws BundleException {
+ File config = OSGiTestsActivator.getContext().getDataFile(getName());
+ config.mkdirs();
+ Map<String, Object> configuration = new HashMap<String, Object>();
+ configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
+ Equinox equinox = new Equinox(configuration);
+
+ equinox.start();
+ BundleContext systemContext = equinox.getBundleContext();
+ try {
+ Bundle b = systemContext.installBundle(installer.getBundleLocation("test.bug471551"));
+ b.start();
+ } catch (BundleException e) {
+ fail("Unexpected error", e); //$NON-NLS-1$
+ }
+
+ equinox.stop();
+ }
+
private static File[] createBundles(File outputDir, int bundleCount) throws IOException {
outputDir.mkdirs();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
index 4b47eecb4..20ed6e700 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
@@ -485,12 +485,9 @@ public class BundleLoader extends ModuleLoader {
for (int i = 1; i < context.length; i++) {
Class<?> clazz = context[i];
// Find the first class in the context which is not BundleLoader or the ModuleClassLoader;
- // We ignore ClassLoader because ModuleClassLoader extends it
- if (clazz != BundleLoader.class && !ModuleClassLoader.class.isAssignableFrom(clazz) && clazz != ClassLoader.class && !clazz.getName().equals("java.lang.J9VMInternals")) { //$NON-NLS-1$
- if (Class.class == clazz) {
- // We ignore any requests from Class (e.g Class.forName case)
- return false;
- }
+ // We ignore ClassLoader because ModuleClassLoader extends it.
+ // We ignore Class because of Class.forName (bug 471551)
+ if (clazz != BundleLoader.class && !ModuleClassLoader.class.isAssignableFrom(clazz) && clazz != ClassLoader.class && clazz != Class.class && !clazz.getName().equals("java.lang.J9VMInternals")) { //$NON-NLS-1$
if (Bundle.class.isAssignableFrom(clazz)) {
// We ignore any requests from Bundle (e.g. Bundle.loadClass case)
return false;
@@ -980,7 +977,8 @@ public class BundleLoader extends ModuleLoader {
String name = packages[i];
if (isDynamicallyImported(name))
continue;
- if (name.equals("*")) { /* shortcut *///$NON-NLS-1$
+ if (name.equals("*")) { //$NON-NLS-1$
+ // shortcut
dynamicAllPackages = true;
return;
}

Back to the top