import jdk.vm.ci.meta.ResolvedJavaType; //导入方法依赖的package包/类
@Override
protected boolean verify(StructuredGraph graph, PhaseContext context) {
final ResolvedJavaType[] bailoutType = new ResolvedJavaType[FORBIDDEN_INSTANCE_OF_CHECKS.length];
for (int i = 0; i < FORBIDDEN_INSTANCE_OF_CHECKS.length; i++) {
bailoutType[i] = context.getMetaAccess().lookupJavaType(FORBIDDEN_INSTANCE_OF_CHECKS[i]);
}
ResolvedJavaMethod method = graph.method();
ResolvedJavaType declaringClass = method.getDeclaringClass();
if (!isTrustedInterface(declaringClass, context.getMetaAccess())) {
for (InstanceOfNode io : graph.getNodes().filter(InstanceOfNode.class)) {
ResolvedJavaType type = io.type().getType();
for (ResolvedJavaType forbiddenType : bailoutType) {
if (forbiddenType.equals(type)) {
String name = forbiddenType.getUnqualifiedName();
// strip outer class
ResolvedJavaType enclosingType = forbiddenType.getEnclosingType();
if (enclosingType != null) {
name = name.substring(enclosingType.getUnqualifiedName().length() + "$".length());
}
throw new VerificationError("Using `op instanceof %s` is not allowed. Use `%s.is%s(op)` instead. (in %s)", name, name, name, method.format("%H.%n(%p)"));
}
}
}
}
return true;
}