Forum: JRuby stack overflow in initializers

Posted by Roger Pack (rogerdpack)
on 2010-09-23 23:10
Hi all.  Wasn't sure if this was a bug or not...

The following code results in a stack overflow

require'java'

module M
  include_package "javax.swing"
  include_package "javax.awt"
  include_package "javax.net"

  class ShowImage < JFrame

    def initialize
      getClass
      # or getToolkit -- same result
    end
  end
  ShowImage.new
end

Is this expected? (if not answer I'll assume it isn't and file a JIRA).

Thanks!
-r
Posted by Nick Sieger (Guest)
on 2010-09-23 23:13
(Received via mailing list)
On Sep 23, 2010, at 16:10 , Roger Pack wrote:

> 
> Is this expected? (if not answer I'll assume it isn't and file a JIRA).
Check JIRA, I think there might already be a long-standing bug on this. 
The basic problem is that you're not calling super() to invoke the Java 
class constructor.

/Nick


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Roger Pack (rogerdpack)
on 2010-09-28 20:00
>> Is this expected? (if not answer I'll assume it isn't and file a JIRA).
> Check JIRA, I think there might already be a long-standing bug on this. 
> The basic problem is that you're not calling super() to invoke the Java 
> class constructor.

Anybody know if this is on jira?

Here are a couple example traces:

C:\dev\ruby\family-history-screen-saver>D:\installs\jruby-1.5.1\bin\jruby 
jtest.crashes.jruby.2.rb
JavaProxy.java:94:in `getJavaClass': java.lang.NullPointerException
        from CallableSelector.java:401:in `classHashCode'
        from CallableSelector.java:394:in `argsHashCode'
        from CallableSelector.java:40:in `matchingCallableArityN'
        from RubyToJavaInvoker.java:180:in `findCallable'
        from InstanceMethodInvoker.java:28:in `call'
        from CachingCallSite.java:279:in `cacheAndCall'
        from CachingCallSite.java:68:in `call'
        from jtest.crashes.jruby.2.rb:28:in `method__3$RUBY$initialize'
        from 
jtest_dot_crashes_dot_jruby_dot_2Invokermethod__3$RUBY$initializeFixed0#initialize:65535:in 
`call'
        from CachingCallSite.java:299:in `cacheAndCall'
        from CachingCallSite.java:117:in `callBlock'
        from CachingCallSite.java:122:in `call'
        from RubyClass.java:793:in `call'
        from DynamicMethod.java:178:in `call'
        from ConcreteJavaProxy.java:132:in `call'
        from CachingCallSite.java:289:in `cacheAndCall'
        from CachingCallSite.java:108:in `call'
        from jtest.crashes.jruby.2.rb:64:in `__file__'
        from jtest.crashes.jruby.2.rb:-1:in `load'
        from Ruby.java:685:in `runScript'
        from Ruby.java:568:in `runNormally'
        from Ruby.java:414:in `runFromMain'
        from Main.java:286:in `run'
        from Main.java:128:in `run'
        from Main.java:97:in `main'

and

...
        at java.lang.StringBuilder.append(StringBuilder.java:115)
        at org.jruby.java.proxies.JavaProxy.getObject(JavaProxy.java:69)
        at 
org.jruby.javasupport.JavaProxyMethods.to_s(JavaProxyMethods.java:53)
        at 
org.jruby.javasupport.JavaProxyMethods$s_method_0_0$RUBYINVOKER$to_s.call(org/jruby/javasupport/JavaProxyMethods$s_method_0_0$RUBYINVOKER$to_s.gen:65535)
        at org.jruby.RubyClass.finvoke(RubyClass.java:598)
        at 
org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:449)
        at org.jruby.RubyObject.toString(RubyObject.java:223)
        at java.lang.String.valueOf(String.java:2826)
        at java.lang.StringBuilder.append(StringBuilder.java:115)
        at org.jruby.java.proxies.JavaProxy.getObject(JavaProxy.java:69)
        at 
org.jruby.javasupport.JavaProxyMethods.to_s(JavaProxyMethods.java:53)
        at 
org.jruby.javasupport.JavaProxyMethods$s_method_0_0$RUBYINVOKER$to_s.call(org/jruby/javasupport/JavaProxyMethods$s_method_0_0$RUBYINVOKER$to_s.gen:65535)
        at org.jruby.RubyClass.finvoke(RubyClass.java:598)
        at 
org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:449)
        at org.jruby.RubyObject.toString(RubyObject.java:223)
        at java.lang.String.valueOf(String.java:2826)
        at java.lang.StringBuilder.append(StringBuilder.java:115)
        at org.jruby.java.proxies.JavaProxy.getObject(JavaProxy.java:69)
        at 
org.jruby.javasupport.JavaProxyMethods.to_s(JavaProxyMethods.java:53)
        at 
org.jruby.javasupport.JavaProxyMethods$s_method_0_0$RUBYINVOKER$to_s.call(org/jruby/javasupport/JavaProxyMethods$s_method_0_0$RUBYINVOKER$to_s.gen:65535)
        at org.jruby.RubyClass.finvoke(RubyClass.java:598)
        at 
org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:449)
        at org.jruby.RubyObject.toString(RubyObject.java:223)
        at java.lang.String.valueOf(String.java:2826)

Thanks!
-r
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.