JavaClass jc = Repository.lookupClass(myOwner.getClassName());
Method[] methods = jc.getMethods();
if (method_no >= methods.length){
throw new InvalidMethodException("METHOD DOES NOT EXIST!");
}
Method method = methods[method_no];
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(RuntimeException re){
return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Bad bytecode in the code array of the Code attribute of method '"+method+"'.");
}