@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE) public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) { Ruby runtime = recv.getRuntime(); IRubyObject finalizer = null; if (args.length == 2) { finalizer = args[1]; if (!finalizer.respondsTo("call")) { throw runtime.newArgumentError("wrong type argument " + finalizer.getType() + " (should be callable)"); } } else { finalizer = runtime.newProc(Block.Type.PROC, block); } IRubyObject obj = args[0]; runtime.getObjectSpace().addFinalizer(obj, finalizer); return runtime.newArray(RubyFixnum.zero(runtime), finalizer); }
@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE) public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) { Ruby runtime = recv.getRuntime(); IRubyObject finalizer; if (args.length == 2) { finalizer = args[1]; if (!finalizer.respondsTo("call")) { throw runtime.newArgumentError("wrong type argument " + finalizer.getType() + " (should be callable)"); } } else { finalizer = runtime.newProc(Block.Type.PROC, block); } IRubyObject obj = args[0]; runtime.getObjectSpace().addFinalizer(obj, finalizer); return runtime.newArray(RubyFixnum.zero(runtime), finalizer); }
@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE) public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) { Ruby runtime = recv.getRuntime(); IRubyObject finalizer; if (args.length == 2) { finalizer = args[1]; if (!finalizer.respondsTo("call")) { throw runtime.newArgumentError("wrong type argument " + finalizer.getType() + " (should be callable)"); } } else { finalizer = runtime.newProc(Block.Type.PROC, block); } IRubyObject obj = args[0]; runtime.getObjectSpace().addFinalizer(obj, finalizer); return runtime.newArray(RubyFixnum.zero(runtime), finalizer); }
@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE) public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) { Ruby runtime = recv.getRuntime(); IRubyObject finalizer = null; if (args.length == 2) { finalizer = args[1]; if (!finalizer.respondsTo("call")) { throw runtime.newArgumentError("wrong type argument " + finalizer.getType() + " (should be callable)"); } } else { finalizer = runtime.newProc(Block.Type.PROC, block); } IRubyObject obj = args[0]; runtime.getObjectSpace().addFinalizer(obj, finalizer); return runtime.newArray(RubyFixnum.zero(runtime), finalizer); }