int n = relativePath.lastIndexOf('/');
if (n < 0)
n = relativePath.length();
String relativeDir = relativePath.substring(0, n);
PackageRef packageRef = getPackageRef(relativeDir);
if (!packageRef.isMetaData() && !contained.containsKey(packageRef)) {
contained.put(packageRef);
// For each package we encounter for the first
// time. Unfortunately we can only do this once
// we found a class since the bcp has a tendency
// to overlap
if (!packageRef.isMetaData()) {
Resource pinfo = jar.getResource(prefix + packageRef.getPath() + "/packageinfo");
getExportVersionsFromPackageInfo(packageRef, pinfo, classpathExports);
}
}
}
// Check class resources, we need to analyze them
if (path.endsWith(".class")) {
Resource resource = jar.getResource(path);
Clazz clazz;
Attrs info = null;
try {
InputStream in = resource.openInputStream();
clazz = new Clazz(this, path, resource);
try {
// Check if we have a package-info
if (relativePath.endsWith("/package-info.class")) {
// package-info can contain an Export annotation
info = new Attrs();
parsePackageInfoClass(clazz, info);
} else {
// Otherwise we just parse it simply
clazz.parseClassFile();
}
}
finally {
in.close();
}
}
catch (Throwable e) {
error("Invalid class file %s (%s)", e, relativePath, e);
e.printStackTrace();
continue next;
}
String calculatedPath = clazz.getClassName().getPath();
if (!calculatedPath.equals(relativePath)) {
// If there is a mismatch we
// warning
if (okToIncludeDirs) // assume already reported
mismatched.put(clazz.getAbsolutePath(), clazz);
} else {
classspace.put(clazz.getClassName(), clazz);
PackageRef packageRef = clazz.getClassName().getPackageRef();
if (!contained.containsKey(packageRef)) {
contained.put(packageRef);
if (!packageRef.isMetaData()) {
Resource pinfo = jar.getResource(prefix + packageRef.getPath() + "/packageinfo");
getExportVersionsFromPackageInfo(packageRef, pinfo, classpathExports);
}
}
if (info != null)
contained.merge(packageRef, false, info);