{
log.debug("Processing JAR file: " + jarUrl.toString());
}
// Use a JarInputStream to read the archive
JarInputStream jarStream = null;
// catch any type of IOException
try
{
// open the JAR stream
jarStream = new JarInputStream(jarUrl.openStream());
// Loop over all entries of the archive
JarEntry jarEntry = null;
while ((jarEntry = jarStream.getNextJarEntry()) != null)
{
// We are only interested in java class files
if (jarEntry.getName().endsWith(".class"))
{
// generate FQCN from entry
String className = getClassName(jarEntry.getName());
// check name against PackageFilter
if (mustProcessClass(className))
{
// analyze this class
processClass(className, jarStream, visitor);
}
}
}
}
catch (IOException e)
{
log.error("Failed to read JAR file: " + jarUrl.toString(), e);
}
finally
{
// Close the stream if it has been opened
if (jarStream != null)
{
try
{
jarStream.close();
}
catch (IOException e)
{
// ignore IO failures on close
}