ClassPath.getTopLevelClasses() returns empty list.
See original GitHub issueSummary ClassPath.getTopLevelClasses() returns empty list when the path of the classloader contains special characters.
How to reproduce this error
- Create a packeage with three classes
- 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());
}
- Copy the whole project to a folder with special characters in its name (like % for example) and execute it.
- 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:
- Created 8 years ago
- Reactions:2
- Comments:20 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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