in src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java [1003:1063]
public VerificationResult do_verify() {
try {
if (verifier.doPass2().equals(VerificationResult.VR_OK)) {
// Okay, class file was loaded correctly by Pass 1
// and satisfies static constraints of Pass 2.
final JavaClass jc = Repository.lookupClass(verifier.getClassName());
final Method[] methods = jc.getMethods();
if (methodNo >= methods.length) {
throw new InvalidMethodException("METHOD DOES NOT EXIST!");
}
final Method method = methods[methodNo];
code = method.getCode();
// No Code? Nothing to verify!
if (method.isAbstract() || method.isNative()) { // IF mg HAS NO CODE (static constraint of Pass 2)
return VerificationResult.VR_OK;
}
// TODO:
// We want a very sophisticated code examination here with good explanations
// on where to look for an illegal instruction or such.
// Only after that we should try to build an InstructionList and throw an
// AssertionViolatedException if after our examination InstructionList building
// still fails.
// That examination should be implemented in a byte-oriented way, i.e. look for
// an instruction, make sure its validity, count its length, find the next
// instruction and so on.
try {
instructionList = new InstructionList(method.getCode().getCode());
} catch (final RuntimeException re) {
return new VerificationResult(VerificationResult.VERIFIED_REJECTED,
"Bad bytecode in the code array of the Code attribute of method '" + tostring(method) + "'.");
}
instructionList.setPositions(true);
// Start verification.
VerificationResult vr = VerificationResult.VR_OK; // default
try {
delayedPass2Checks();
} catch (final ClassConstraintException | ClassFormatException cce) {
vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage());
return vr;
}
try {
pass3StaticInstructionChecks();
pass3StaticInstructionOperandsChecks();
} catch (final StaticCodeConstraintException | ClassFormatException scce) {
vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, scce.getMessage());
} catch (final ClassCastException cce) {
vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Class Cast Exception: " + cce.getMessage());
}
return vr;
}
// did not pass Pass 2.
return VerificationResult.VR_NOTYET;
} catch (final ClassNotFoundException e) {
// FIXME: maybe not the best way to handle this
throw new AssertionViolatedException("Missing class: " + e, e);
}
}