// construct verifier for class file
Verifier verifier = VerifierFactory.getVerifier(file.getName());
// run validation in stages with error handling for each stage
boolean verified = false;
VerificationResult vr = verifier.doPass1();
if (vr.getStatus() == VerificationResult.VERIFIED_OK) {
vr = verifier.doPass2();
if (vr.getStatus() == VerificationResult.VERIFIED_OK) {
Method[] methods = file.getRawClass().getMethods();
for (int j = 0; j < methods.length; j++) {
vr = verifier.doPass3a(j);
if (vr.getStatus() == VerificationResult.VERIFIED_OK) {
vr = verifier.doPass3b(j);
}
if (vr.getStatus() == VerificationResult.VERIFIED_OK) {
verified = true;
} else {
System.out.println
("Verification failure on method " +
methods[j].getName() + " of class " +
file.getName() + ":");
System.out.println(" " + vr.toString());
}
}
} else {
System.out.println("Verification failure on class " +
file.getName() + ":");
System.out.println(" " + vr.toString());
}
} else {
System.out.println("Verification failure on class " +
file.getName() + ":");
System.out.println(" " + vr.toString());
}
return verified;
} catch (Exception ex) { // catch BCEL errors
System.out.println("BCEL failure:");