Open GoogleCodeExporter opened 8 years ago
It appears that Reflections is mistakenly assuming the URL is a JAR file
because of the .jar extension without first checking to see if it is actually a
directory (?). The following seems to work around this issue for me, but is
probably not the best solution (do this before constructing the Reflections
object).
// Create a custom Reflections VFS URL type to handle exploded jar directories (the
// reflection code should probably test to see if a URL with a jar extension is
// actually a JAR file).
Vfs.UrlType explodedJarUrlType = new Vfs.UrlType()
{
/**
* Returns true if the URL is a directory on the filesystem.
*/
public boolean matches(URL url)
{
try
{
// Fairly ugly way to determine if the URL is a directory.
File file = new File(url.toURI());
return file.isDirectory();
}
catch (URISyntaxException e)
{
return false;
}
}
/**
* Returns the Reflections SystemDir VFS type.
*/
public Vfs.Dir createDir(final URL url)
{
try
{
File file = new File(url.toURI());
return new SystemDir(file);
}
catch (URISyntaxException e)
{
// Cannot happen due to matches() method
log.error("The URL is not in the correct format");
return null;
}
}
};
// Replace the default URL types, inserting our custom URL type to the beginning
// of the list.
List<Vfs.UrlType> urlTypes = Vfs.getDefaultUrlTypes();
urlTypes.add(0, explodedJarUrlType);
Vfs.setDefaultURLTypes(urlTypes);
Original comment by geech1...@gmail.com
on 24 Sep 2013 at 10:31
Original issue reported on code.google.com by
cfous...@gmail.com
on 20 Sep 2013 at 4:51