}
}
}
}
if (f == null) {
throw new AssertionViolatedException("Field '"+field_name+"' not found?!?");
}
}
if (f.isProtected()){
ObjectType classtype = o.getClassType(cpg);
ObjectType curr = new ObjectType(mg.getClassName());
if ( classtype.equals(curr) ||
curr.subclassOf(classtype) ){
Type t = stack().peek();
if (t == Type.NULL){
return;
}
if (! (t instanceof ObjectType) ){
constraintViolated(o, "The 'objectref' must refer to an object that's not an array. Found instead: '"+t+"'.");
}
ObjectType objreftype = (ObjectType) t;
if (! ( objreftype.equals(curr) ||
objreftype.subclassOf(curr) ) ){
//TODO: One day move to Staerk-et-al's "Set of object types" instead of "wider" object types
// created during the verification.
// "Wider" object types don't allow us to check for things like that below.
//constraintViolated(o, "The referenced field has the ACC_PROTECTED modifier, and it's a member of the current class or a superclass of the current class. However, the referenced object type '"+stack().peek()+"' is not the current class or a subclass of the current class.");
}
}
}
// TODO: Could go into Pass 3a.
if (f.isStatic()){
constraintViolated(o, "Referenced field '"+f+"' is static which it shouldn't be.");
}
} catch (ClassNotFoundException e) {
// FIXME: maybe not the best way to handle this
throw new AssertionViolatedException("Missing class: " + e.toString());
}
}