Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.jruby.javasupport.JavaClass.getMethods generates NoMethodError #3239

Closed
CeesZ opened this issue Aug 9, 2015 · 8 comments
Closed

org.jruby.javasupport.JavaClass.getMethods generates NoMethodError #3239

CeesZ opened this issue Aug 9, 2015 · 8 comments

Comments

@CeesZ
Copy link

CeesZ commented Aug 9, 2015

I tried to upgrade an existing program to work with jruby-complete-1.7.21.jar.
The program halts with an error:
NomethodError: undefined method 'getMethods' for #Class:03259fa
Looking up the code, it concerns the following call:
org.jruby.javasupport.JavaClass.getMethods(qtclass)
p [qtclass, qtclass.class] #=> [Java::ComTrolltechQt::QtInfo, Class]
Further checking shows this code works in 1.7.19 but also fails in 1.7.20.1

Is this method now obsolete or can this be due to a bug?

@kares
Copy link
Member

kares commented Aug 13, 2015

@CeesZ seems like a regression, could we have your full back/stack trace please?
... also are you doing org.jruby.javasupport.JavaClass.getMethods(qtclass) from Ruby or Java?

@CeesZ
Copy link
Author

CeesZ commented Aug 13, 2015

Thanks for looking at this. The call is made from a Ruby program. Following are two back traces; the first one if I run the program from a jar based on jruby-complete, and the second one if I run it directly using the jruby compiler. They both generate the same error and essentially generate the same back trace.

(stack, running from a jar based on jruby-complete-1.7.21)
NoMethodError: undefined method `getMethods' for #Class:0x7a356
setup_qt_signals at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/lib/ruby/qt_connect-1.6.1/lib/qt_connect/qt_jbindings.rb:341
const_missing at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/lib/ruby/qt_connect-1.6.1/lib/qt_connect/qt_jbindings.rb:323
Qt at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/lib/ruby/qt_connect-1.6.1/lib/qt_connect/qt_jbindings.rb:720
(root) at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/lib/ruby/qt_connect-1.6.1/lib/qt_connect/qt_jbindings.rb:169
require at org/jruby/RubyKernel.java:1040
(root) at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
require at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
require at file:/C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/app/jruby_bootstrap.rb:201
require at org/jruby/RubyKernel.java:1040
(root) at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/lib/ruby/qt_connect-1.6.1/lib/qt_connect.rb:6
(root) at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
require at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
require at org/jruby/RubyKernel.java:1040
require at file:/C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/app/jruby_bootstrap.rb:201
(root) at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/lib/ruby/qt_connect-1.6.1/lib/Qt.rb:2
(root) at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
require at org/jruby/RubyKernel.java:1040
require at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
require at file:/C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/app/jruby_bootstrap.rb:201
(root) at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/app/xlsplashup.rb:4
require at org/jruby/RubyKernel.java:1040
(root) at /C:/Program Files (x86)/XLibriz/lib/java/XLibriz.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
(root) at -e:1

(stack, running from the filesystem using jruby-1.7.21.exe)
NoMethodError: undefined method `getMethods' for #Class:0xc2e211
setup_qt_signals at C:/Projects/XLibriz/lib/ruby/qt_connect-1.6.1/lib/qt_connect/qt_jbindings.rb:341
const_missing at C:/Projects/XLibriz/lib/ruby/qt_connect-1.6.1/lib/qt_connect/qt_jbindings.rb:323
Qt at C:/Projects/XLibriz/lib/ruby/qt_connect-1.6.1/lib/qt_connect/qt_jbindings.rb:720
(root) at C:/Projects/XLibriz/lib/ruby/qt_connect-1.6.1/lib/qt_connect/qt_jbindings.rb:169
require at org/jruby/RubyKernel.java:1040
(root) at C:/Packages/jruby-1.7.21/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
require at C:/Packages/jruby-1.7.21/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
require at app\jruby_bootstrap.rb:201
require at org/jruby/RubyKernel.java:1040
(root) at C:/Projects/XLibriz/lib/ruby/qt_connect-1.6.1/lib/qt_connect.rb:6
(root) at C:/Packages/jruby-1.7.21/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
require at C:/Packages/jruby-1.7.21/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
require at org/jruby/RubyKernel.java:1040
require at app\jruby_bootstrap.rb:201
(root) at C:/Projects/XLibriz/lib/ruby/qt_connect-1.6.1/lib/Qt.rb:2
(root) at C:/Packages/jruby-1.7.21/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
require at org/jruby/RubyKernel.java:1040
require at C:/Packages/jruby-1.7.21/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
require at app\jruby_bootstrap.rb:201
(root) at C:/Projects/XLibriz/app/xlsplashup.rb:4

@CeesZ CeesZ closed this as completed Aug 13, 2015
@CeesZ CeesZ reopened this Aug 13, 2015
@CeesZ
Copy link
Author

CeesZ commented Aug 13, 2015

Sorry pushed the wrong button. Did not intend to close the issu

@kares
Copy link
Member

kares commented Aug 13, 2015

where did you get qt_connect 1.6.1 ... could we see its sources as the 1.5 lines do not match ?
also do you think its possible to reproduce in a way that would not need a lot of hustle? thanks

@CeesZ
Copy link
Author

CeesZ commented Aug 13, 2015

I am the author of qt_connect . I am waiting for some bugs in qtjambi 4.8.6 to be cleared and would like to get it working with jruby-9.0.0.0 before releasing the new version to GitHub. So far I did not make many changes from 1.5. What is the easiest way to get you the interim sources? It may not be trivial to isolate the bit of code from the rest, but I will give it some thought

@CeesZ
Copy link
Author

CeesZ commented Aug 13, 2015

The following short program demonstrates the problem without having to go in the complicating factors of the Qt interface:

require 'java'
javaclass = java.io.FileOutputStream
pp org.jruby.javasupport.JavaClass.getMethods(javaclass).to_a

jrb1719>jruby test3.rb
[public final native java.lang.Class java.lang.Object.getClass(),
protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException,
public final java.io.FileDescriptor java.io.FileOutputStream.getFD() throws java.io.IOException,
public java.nio.channels.FileChannel java.io.FileOutputStream.getChannel(),
public boolean java.lang.Object.equals(java.lang.Object),
public native int java.lang.Object.hashCode(),
public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException,
public final void java.lang.Object.wait() throws java.lang.InterruptedException,
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException,
public void java.io.OutputStream.close() throws java.io.IOException,
public void java.io.OutputStream.flush() throws java.io.IOException,
public final native void java.lang.Object.notify(),
public void java.io.OutputStream.write(byte[],int,int) throws java.io.IOException,
public void java.io.OutputStream.write(byte[]) throws java.io.IOException,
public abstract void java.io.OutputStream.write(int) throws java.io.IOException,
protected void java.lang.Object.finalize() throws java.lang.Throwable,
public java.lang.String java.lang.Object.toString(),
public final native void java.lang.Object.notifyAll()]

jrb1721>jruby test3.rb
NoMethodError: undefined method 'getMethods' for #Class:0x17d9933

@kares
Copy link
Member

kares commented Aug 13, 2015

oh my bad, did not notice that method is actually gone (thought this is a Java Class conversion regression). it was really intended internal ... would you mind refactoring to no longer use it ?

you can either simply use qtclass.java_class.getMethods to get the "plain-java" ones or qtclass.java_class.java_instance_methods (and java_class_methods for static ones) although be advised that the later currently does not return "raw" java.lang.Method objects

@CeesZ
Copy link
Author

CeesZ commented Aug 13, 2015

OK, thanks. That should be a simple solution

@CeesZ CeesZ closed this as completed Aug 13, 2015
@kares kares added this to the Invalid or Duplicate milestone Aug 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants