File operations that work in my simple JRuby program do not work in my Swing GUI based program. The attached file "filetest.rb" reads in a text file (itself) and sends it to the console with a "puts". That code was copied into the other attachment "gui_filetest.rb", which should do the same thing when triggered by my popup menu selection. The line that causes the error follows: # read_from_disk # This causes an error The error message is at the very bottom of the file, between =begin and =end.
on 2011-07-23 21:25
on 2011-07-25 13:31
Hi Charles, The problem was a simple Ruby mistake that I made. However, the error message mentioned something relative to Java, so I thought that somehow my Ruby file-related commands were somehow clashing with Java. After a while, I stopped looking for Java-related issues, and then finally saw that it was just a simple Ruby variable-scope issue. I had been so focused on the new aspects of Java and Swing, that I got sloppy with Ruby. Regards, Gary
on 2011-07-25 21:53
Ok, it sounds like you may have gotten a Java error. Can you show me? If it's a Java error/exception, that's almost always a bug; we should be re-throwing a Ruby exception with an appropriate message. If it is a Ruby exception but has a bad Java-related error message, that's something we'd want to fix too. - Charlie
on 2011-07-25 22:03
Charlie, Here is the error msg: Exception in thread "AWT-EventQueue-0" org.jruby.exceptions.RaiseException: (TypeError) can't convert nil into String at org.jruby.RubyFileTest.exist?(org/jruby/RubyFileTest.java:129) at TextStatus.read_from_disk(./gui_filetest.rb:30) at TextStatus.create_popup(./gui_filetest.rb:47) at org.jruby.RubyProc.call(org/jruby/RubyProc.java:268) at org.jruby.RubyProc.call(org/jruby/RubyProc.java:232) When I looked at the error, I saw the ".java" in the error msg and thought that perhaps Java had something to do with it. However, the error was that my filename variable was not readable within the scope of the class. Once I corrected that, it all worked. So Java had nothing to do with it. Regards, Gary
on 2011-07-25 22:10
Ahh I see...so the issue here is that we're raising an appropriate Ruby error, but it is eventually handled by the Java logic in the AWT event thread. The .java files in the trace are to show the core class methods, which are mostly implemented in Java in JRuby. In any case, I believe this is being handled correctly by JRuby, and it's just an interaction issue with AWT that presented it in an odd way. Thank you! - Charlie
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
Log in with Google account | Log in with Yahoo account
No account? Register here.