question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ClassPath.getTopLevelClasses() returns empty list.

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
Blackdreadcommented, Mar 13, 2019

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

2reactions
UnAfraidcommented, Mar 15, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Guava getTopLevelClasses returns empty set
I used a decompiler so I could manually shade the ClassPath class from a newer Guava into my own code, and imported that....
Read more >
ClassPath.getTopLevelClasses() still returns null for java ...
I'm migrating a project to Java 10, and we use ClassPath.getTopLevelClasses() to grab classes available in various packages.
Read more >
Google Guava getTopLevelClasses returns empty set-Java
I used a decompiler so I could manually shade the ClassPath class from a newer Guava into my own code, and imported that....
Read more >
Example usage for com.google.common.reflect ClassPath ...
Example usage for com.google.common.reflect ClassPath getTopLevelClasses. List of ... Returns all top level classes whose package name is packageName .
Read more >
com.google.common.reflect.ClassPath.getTopLevelClasses ...
Returns all top level classes whose package name is {@code packageName}. ... loadClassesInPackage() throws IOException { List<Class<?>> classes = Lists.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found