// Compute the resource name
String resourceName = descriptor.toResourceName();
// Look up the codebase entry for the resource
ICodeBaseEntry codeBaseEntry;
try {
codeBaseEntry = analysisCache.getClassPath().lookupResource(resourceName);
} catch (ResourceNotFoundException e) {
// Allow loading javax.annotation's from our own classpath - in case we analyze projects
// using 3rd party nullness annotations (which do not have jsr305 classes on classpath)
if(resourceName.startsWith("javax/annotation/")){
codeBaseEntry = new VirtualCodeBaseEntry(descriptor);
} else {
throw new MissingClassException(descriptor, e);
}
}
byte[] data;
if (codeBaseEntry instanceof ZipInputStreamCodeBaseEntry) {
data = ((ZipInputStreamCodeBaseEntry) codeBaseEntry).getBytes();
} else {
try {
// Create a ByteArrayOutputStream to capture the class data
int length = codeBaseEntry.getNumBytes();
InputStream in = codeBaseEntry.openResource();
if (length >= 0) {
data = IO.readAll(in, length);
} else {
data = IO.readAll(in);
}