* @return new class spec instance
* @throws IOException for any I/O error
*/
protected ClassSpec toClassSpec(File file) throws IOException {
final long size = file.length();
final ClassSpec spec = new ClassSpec();
final InputStream is = new FileInputStream(file);
try {
if (size <= (long) Integer.MAX_VALUE) {
final int castSize = (int) size;
byte[] bytes = new byte[castSize];
int a = 0, res;
while ((res = is.read(bytes, a, castSize - a)) > 0) {
a += res;
}
// done
is.close();
spec.setBytes(bytes);
return spec;
} else {
throw new IOException("Resource is too large to be a valid class file");
}
} finally {