Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2009-09-22 17:02:43 +0000
committerThomas Watson2009-09-22 17:02:43 +0000
commitb458b2b8603f3b90ee35d79c80383d308333ea7b (patch)
tree533b6f8c5f1582ecfb6a1445fb93e90fd82296f4
parentfcb08770a51e77a756a0d48e928cff3f86a07c15 (diff)
downloadrt.equinox.framework-b458b2b8603f3b90ee35d79c80383d308333ea7b.tar.gz
rt.equinox.framework-b458b2b8603f3b90ee35d79c80383d308333ea7b.tar.xz
rt.equinox.framework-b458b2b8603f3b90ee35d79c80383d308333ea7b.zip
Bug 289983 NullPointerException while calling getResources() on system bundle
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java22
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/SystemBundleLoader.java59
2 files changed, 79 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
index 5a00f9807..39ced51fc 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
@@ -1385,6 +1385,28 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
doTestArrayTypeLoad("[[Lorg.eclipse.osgi.tests.bundles.ArrayTest;"); //$NON-NLS-1$
}
+ public void testSystemBundleGetResources01() {
+ Bundle systemBundle = OSGiTestsActivator.getContext().getBundle(0);
+ Enumeration resources = null;
+ try {
+ resources = systemBundle.getResources("hookconfigurators.properties");
+ } catch (IOException e) {
+ fail("Failed to get resources", e);
+ }
+ assertNotNull("Resources is null", resources);
+ }
+
+ public void testSystemBundleGetResources02() {
+ Bundle systemBundle = OSGiTestsActivator.getContext().getBundle(0);
+ Enumeration resources = null;
+ try {
+ resources = systemBundle.getResources("java/lang/test.resource");
+ } catch (IOException e) {
+ fail("Failed to get resources", e);
+ }
+ assertNull("Resources is not null", resources);
+ }
+
private void doTestArrayTypeLoad(String name) {
try {
Class arrayType = OSGiTestsActivator.getContext().getBundle().loadClass(name);
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 4968454cd..0408149b5 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * Copyright (c) 2003, 2009 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
@@ -13,12 +13,14 @@ package org.eclipse.osgi.internal.loader;
import java.io.IOException;
import java.net.URL;
+import java.security.ProtectionDomain;
import java.util.Enumeration;
import java.util.HashSet;
-import org.eclipse.osgi.framework.adaptor.BundleData;
+import org.eclipse.osgi.framework.adaptor.*;
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;
/**
@@ -188,4 +190,57 @@ public class SystemBundleLoader extends BundleLoader {
public boolean isEEPackage(String pkgName) {
return eePackages.contains(pkgName);
}
+
+ BundleClassLoader createBCL(BundleProtectionDomain pd, String[] cp) {
+ return new BundleClassLoader() {
+
+ public Bundle getBundle() {
+ return SystemBundleLoader.this.getBundle();
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException {
+ return SystemBundleLoader.this.loadClass(name);
+ }
+
+ public void initialize() {
+ // nothing
+ }
+
+ public Enumeration getResources(String name) throws IOException {
+ return findLocalResources(name);
+ }
+
+ public URL getResource(String name) {
+ return SystemBundleLoader.this.findLocalResource(name);
+ }
+
+ public ClassLoader getParent() {
+ return SystemBundleLoader.this.classLoader.getParent();
+ }
+
+ public ClassLoaderDelegate getDelegate() {
+ return SystemBundleLoader.this;
+ }
+
+ public Enumeration findLocalResources(String resource) {
+ return SystemBundleLoader.this.findLocalResources(resource);
+ }
+
+ public URL findLocalResource(String resource) {
+ return getResource(resource);
+ }
+
+ public Class findLocalClass(String classname) throws ClassNotFoundException {
+ return SystemBundleLoader.this.findLocalClass(classname);
+ }
+
+ public void close() {
+ // nothing
+ }
+
+ public void attachFragment(BundleData bundledata, ProtectionDomain domain, String[] classpath) {
+ // nothing
+ }
+ };
+ }
}

Back to the top