public void visitGETSTATIC(final GETSTATIC o) {
try {
final String field_name = o.getFieldName(cpg);
final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName());
final Field[] fields = jc.getFields();
Field f = null;
for (final Field field : fields) {
if (field.getName().equals(field_name)) {
f = field;
break;
}
}
if (f == null) {
throw new AssertionViolatedException("Field '" + field_name + "' not found in " + jc.getClassName());
}
if (! (f.isStatic())) {
constraintViolated(o, "Referenced field '"+f+"' is not static which it should be.");
}
} catch (final ClassNotFoundException e) {
throw new AssertionViolatedException("Missing class: " + e, e);
}
}
|