I’m trying to use a method from a Java class whose parameter type is char, but I can’t seem to get it to work. If I try constructing a new instance of java.lang.Character, it throws the error:
org.jruby.exceptions.RaiseException: (TypeError) cannot convert instance of class org.jruby.java.proxies.ConcreteJavaProxy to char
...[stacktrace; not important]...
When I try to create a new instance of Java::char using Java::char.java_class.new(my_number), it raises java.lang.StackOverflowError. Well, in the jirb, it gives me this:
NoMethodError: undefined method `new' for class char:Java::JavaClass
or if I use Java::char.to_java.new(my_number), it gives the error:
NoMethodError: undefined method `new' for #<Class:0x1556b277f>
I’m really stuck on what to do; all I need is to get a java character somehow that can be passed through the type system successfully. Any ideas?
Figured it out; apparently Jruby will coerce Ruby Fixnums into Java Characters if needed. Problem solved.