Skip to content

Documentation of ClassPath#getResources() is misleading #2712

Open

Description

@rkosegi

Javadocs on ClassPath#getResources() reads:

Returns all resources loadable from the current class path, including the class files of all
loadable classes but excluding the "META-INF/MANIFEST.MF" file

This is not exactly true for files which has same path relative to JAR.
Eg. if I want to load files all resources named "META-INF/schema.xml" from all JAR files on classpath, it will pick only last one, due to nature of backing ImmutableSet.
It should be either mentioned in javadocs, or allow "duplicates" for example by using ImmutableList or by changing ResourceInfo#equals to consider URL instead of just resourceName;

Activity

  1. removed their assignment
    on Sep 6, 2019
  2. cpovirk commented on Aug 15, 2026

    @cpovirk
    Member

    The other alternative here, which you can see hints of in the current code, is for a single ResourceInfo instance to expose access to multiple resources. We had tried this internally for a bit but eventually backed out the one user.

    I'm not sure what the best thing to do here is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions