felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Gruber <ogru...@us.ibm.com>
Subject Bug in Bundle.getEntry ?
Date Tue, 19 Sep 2006 16:02:06 GMT
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


Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message