guava: ClassPath.getTopLevelClasses() returns empty list.

Summary ClassPath.getTopLevelClasses() returns empty list when the path of the classloader contains special characters.

How to reproduce this error

  1. Create a packeage with three classes
  2. Create the following unit test
    @Test
    public void testMain() throws Exception {
        ClassLoader loader = this.getClass().getClassLoader();
        ClassPath p = ClassPath.from(loader);
        ImmutableSet<ClassPath.ClassInfo> list = p.getTopLevelClasses("testpackage");
        Assert.assertEquals(3, list.size());
    }
  1. Copy the whole project to a folder with special characters in its name (like % for example) and execute it.
  2. The test will fail. If you copy the project to a folder without special characters in its path the test will pass.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 20 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Does guava ClassPath class intend to support the spring boot jar layout?

Try with 24.0, it works for me even on java 9

Sorry, this will be in 22.0.