Implementation of Bundle.loadClass() from OSGi R4.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@349969 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/org/apache/felix/framework/BundleImpl.java b/framework/src/org/apache/felix/framework/BundleImpl.java
index 3f5d58c..c928877 100644
--- a/framework/src/org/apache/felix/framework/BundleImpl.java
+++ b/framework/src/org/apache/felix/framework/BundleImpl.java
@@ -149,8 +149,7 @@
public Class loadClass(String name) throws ClassNotFoundException
{
- // TODO: Implement Bundle.loadClass()
- return null;
+ return m_felix.loadBundleClass(this, name);
}
public Enumeration getResources(String name) throws IOException
diff --git a/framework/src/org/apache/felix/framework/Felix.java b/framework/src/org/apache/felix/framework/Felix.java
index be29ea2..6083d88 100644
--- a/framework/src/org/apache/felix/framework/Felix.java
+++ b/framework/src/org/apache/felix/framework/Felix.java
@@ -1140,6 +1140,25 @@
}
/**
+ * Implementation for Bundle.loadClass().
+ **/
+ protected Class loadBundleClass(BundleImpl bundle, String name) throws ClassNotFoundException
+ {
+ try
+ {
+ return bundle.getInfo().getCurrentModule().getClassLoader().loadClass(name);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ // The spec says we must throw a framework error.
+ fireFrameworkEvent(
+ FrameworkEvent.ERROR, bundle,
+ new BundleException(ex.getMessage()));
+ throw ex;
+ }
+ }
+
+ /**
* Implementation for Bundle.start().
**/
protected void startBundle(BundleImpl bundle, boolean record)