Attempted to create a java.lang.reflect.Proxy using the following code:
require 'java';
include_class('java.lang.reflect.InvocationHandler');
include_class('java.lang.reflect.Proxy') {
include_class('java.lang.Runnable');
include_class('java.util.concurrent.Callable');
include_class("java.lang.reflect.Array") {
include_class("java.lang.Class") {
class MyRunnable < InvocationHandler
def invoke(obj, name, args)
puts name + " called"
end
end
include_class('java.lang.Runnable')
types = JArray.newInstance(JClass, 2);
types[0] = Runnable
types[1] = Callable
m = MyRunnable.new
r = JProxy.newProxyInstance(nil, types, m);
puts r.kind_of?(Runnable)
puts r.kind_of?(Callable)
---------------
At JProxy.newInstance line "stack level too deep" error is thrown; searched for this string in JRuby 0.9.0 source base - found that in org.jruby.evaluator.EvaluationState class.