private Set<String> computeRequiredPackages(Bundle bundle) throws IOException {
Set<String> requiredPkgs = new HashSet<String>();
File moduleFile = new File(bundle.getMd().getLocations()[0]);
String classpath = moduleFile.getAbsolutePath();
JarFile moduleJar = new JarFile(moduleFile);
ClassFileLoader cfl = ClassFileLoaderFactory.newInstance(new Object[]{classpath});
final String classExt = ".class";
for (Enumeration<JarEntry> entries = moduleJar.entries(); entries.hasMoreElements();) {
JarEntry je = entries.nextElement();
if (je.getName().endsWith(classExt)) {
String className = Util.convertToExternalClassName(je.getName().substring(0, je.getName().length() - classExt.length()));
ClassFile cf = null;
try {
cf = cfl.load(className);
for (String c : cf.getAllReferencedClassNames()) {
requiredPkgs.add(Util.getPackageName(c));
}
} catch (IOException e) {
logger.logp(Level.FINE, "PackageAnalyser", "computeRequiredPackages", "Skipping analysis of {0} as the following exception was thrown:\n {1}", new Object[]{className, e});