Code with Finding: |
class InstConstraintVisitor {
/**
* Assures the ReferenceType r is initialized (or Type.NULL).
* Formally, this means (!(r instanceof UninitializedObjectType)), because
* there are no uninitialized array types.
* @throws StructuralCodeConstraintException if the above constraint is not satisfied.
*/
private void referenceTypeIsInitialized(Instruction o, ReferenceType r){
if (r instanceof UninitializedObjectType){
constraintViolated(o, "Working on an uninitialized object '"+r+"'.");
}
}
}
class InstConstraintVisitor {
/**
* Ensures the specific preconditions of the said instruction.
*/
@Override
public void visitINSTANCEOF(INSTANCEOF o){
// The objectref must be of type reference.
Type objectref = stack().peek(0);
if (!(objectref instanceof ReferenceType)){
constraintViolated(o, "The 'objectref' is not of a ReferenceType but of type "+objectref+".");
}
//else{
// referenceTypeIsInitialized(o, (ReferenceType) objectref);
//}
// The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the
// current class (�3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant
// pool item at the index must be a symbolic reference to a class, array, or interface type.
Constant c = cpg.getConstant(o.getIndex());
if (! (c instanceof ConstantClass)){
constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'.");
}
}
}
|