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
- 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.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 2
- Comments: 20 (7 by maintainers)
Commits related to this issue
- Handle escaped characters properly when reading ClassPath entries from file:// urls. (Fixes #2152) — committed to ColinChartier/guava by ColinChartier 8 years ago
- Handle escape characters properly while scraping ClassPaths. (fixes #2152) — committed to ColinChartier/guava by ColinChartier 8 years ago
- Handle escape characters properly while scraping ClassPaths. (fixes #2152) — committed to ColinChartier/guava by ColinChartier 8 years ago
- To fix external bug https://github.com/google/guava/issues/2152. This code follows the article emcmanus mentioned: https://community.oracle.com/blogs/kohsuke/2007/04/25/how-convert-javaneturl-javaiof... — committed to google/guava by deleted user 7 years ago
- Minor update to 1.0.3 fixing bug in guava https://github.com/google/guava/issues/2152 — committed to UnAfraid/Plugins by UnAfraid 7 years ago
- Version 1.0.3 Fixing bug in guava https://github.com/google/guava/issues/2152 Minor update to eclipse templates — committed to UnAfraid/Plugins by UnAfraid 7 years ago
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.