return false;
}
private static Dependencies loadDepencencies(String jdkFileName)
{
Dependencies dependencies= new Dependencies();
// This is a shortcut, in case we already have the analytical data about
// the dependencies loaded and stored on the file system. If so, we use
// this data.
File resultsFile= new File(RESULTS_FILENAME);
if (resultsFile.exists())
{
Log.debug(TAG, "Loading results from " + RESULTS_FILENAME + " ...");
ObjectInputStream ois;
try
{
ois= new ObjectInputStream(new FileInputStream(resultsFile));
dependencies= (Dependencies) ois.readObject();
ois.close();
Log.debug(TAG, "Loaded results from file: " + dependencies.size());
}
catch (FileNotFoundException e)
{
e.printStackTrace();
return null;
}
catch (IOException e)
{
e.printStackTrace();
return null;
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
return null;
}
}
else
{
// If there is no stored result, we nee to analyze the classes
// first.
// First the class files are loaded.
UniversalFile library= UniversalFileCreator.createDirectory(null, jdkFileName);
UniversalFile[] classes= library.listFilesRecursively(new UniversalFileFilter()
{
public boolean accept(UniversalFile file)
{
return file.getName().toLowerCase().endsWith(".class");
}
});
Log.debug(TAG, "Analyzing " + classes.length + " classes.");
final String basePath= library.getAbsolutePath();
// We go through all the class files and get their dependencies.
for (UniversalFile clazz : classes)
{
String fileName= clazz.getRelativePath(basePath).replace('\\', '.');
Dependencies.ClassDeps classDeps= dependencies.getDepsForClass(fileName.substring(0, fileName.length() - 6).replace(File.separatorChar, '.'));
getAllDependencies(clazz.getFileAsBytes(), fileName, classDeps);
}
// Store results on disk so we save time when executing this a
// second time.