public static class JavaCallGenerator implements HandleGenerator {
@Override
public boolean canGenerate(JRubyCallSite site, RubyClass cls, DynamicMethod method) {
NativeCall nativeCall = method.getNativeCall();
if (nativeCall != null) {
// has an explicit native call path
if (nativeCall.isJava()) {
if (!Options.INVOKEDYNAMIC_INVOCATION_JAVA.load()) {
throw new IndirectBindingException("direct Java dispatch not enabled");
}
// if Java, must:
// * match arity <= 3
// * not be passed a block (no coercion yet)
// * be a normal wrapper around a class or module (not a Ruby subclass)
if (nativeCall.getNativeSignature().length != site.arity()
|| site.arity() > 3
|| site.isIterator()
|| !cls.getJavaProxy()) {
throw new IndirectBindingException("Java call arity mismatch or > 3 args");
}