Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

JarClassLoader.findResource() not working for packages

Gopal Shah
2013-05-29
2013-05-29
  • Gopal Shah
    Gopal Shah
    2013-05-29

    I am using the reflections API ClasspathHelper.forPackage("com.x.y.z", this.getClass.getClassLoader()). The reflections API internally would make a call to classLoader.getResources() which would call findResource() method. What I have observed is JarClassLaoder.findResource() doesn't work for packages. What I could interpret from the JarClassLoader source code is that during loading of main class we iterate through jar entries in all the jars and cache it in byteCode object. Since the jar entries are only for classes, when findResource() for a package is invoked, it doesn't find the resource entry in byteCode and hence doesn't work for a package name.
    Is my interpretation correct? Do you think it is a missing feature? Could we add it to feature request list?