I think I found a bug in the implementation of URL Bundle.getEntry(String name);
It raises a ClassCastException when called on the system bundle since its content loader
is not a ContentLoaderImpl but actually a SystemBundleContentLoader. :-(

class BundleImpl        
    public URL getEntry(String name)
    {
        Object sm = System.getSecurityManager();

        if (sm != null)
        {
            try
            {
                ((SecurityManager) sm).checkPermission(new AdminPermission(this,
                    AdminPermission.RESOURCE));
            }
            catch (Exception e)
            {
                return null; // No permission
            }
        }

        return m_felix.getBundleEntry(this, name);
    }

class Felix
    /**
     * Implementation for Bundle.getEntry().
    **/
    protected URL getBundleEntry(BundleImpl bundle, String name)
    {
        if (bundle.getInfo().getState() == Bundle.UNINSTALLED)
        {
            throw new IllegalStateException("The bundle is uninstalled.");
        }
==>>        return ((ContentLoaderImpl) bundle.getInfo().getCurrentModule()
            .getContentLoader()).getResourceFromContent(name);
    }

Here is a patch for this problem.

       

It is basically moving the getResourceFromContent from ContentLoaderImpl to Felix,
which required to modify the FindEntriesEnumeration slightly.

Best regards,

Olivier Gruber, Ph.D.
Persistent & Distributed Object Platforms and Frameworks
IBM TJ Watson Research Center

Reply via email to