Modified to return a URL representing the "root" of the bundle JAR file
when Bundle.getEntry("/") is invoked.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@375223 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java
index a81e278..8f4379a 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java
@@ -114,6 +114,7 @@
public URL getResource(String name)
{
URL url = null;
+
// Remove leading slash, if present.
if (name.startsWith("/"))
{
@@ -165,19 +166,29 @@
{
URL url = null;
- // Remove leading slash, if present.
- if (name.startsWith("/"))
+ // Check for the special case of "/", which represents
+ // the root of the bundle according to the spec.
+ if (name.equals("/"))
{
- name = name.substring(1);
+ url = getURLPolicy().createURL("0/");
}
- // Check the module content.
- if (getContent().hasEntry(name))
+ if (url == null)
{
- // Module content URLs start with 0, whereas module
- // class path URLs start with the index into the class
- // path + 1.
- url = getURLPolicy().createURL("0/" + name);
+ // Remove leading slash, if present.
+ if (name.startsWith("/"))
+ {
+ name = name.substring(1);
+ }
+
+ // Check the module content.
+ if (getContent().hasEntry(name))
+ {
+ // Module content URLs start with 0, whereas module
+ // class path URLs start with the index into the class
+ // path + 1.
+ url = getURLPolicy().createURL("0/" + name);
+ }
}
return url;