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

Java error when using .add_change_listener after jarification #39

Closed
Hobogrammer opened this issue Mar 31, 2013 · 12 comments
Closed

Java error when using .add_change_listener after jarification #39

Hobogrammer opened this issue Mar 31, 2013 · 12 comments

Comments

@Hobogrammer
Copy link

During development the usage of the .add_change_listener method works correctly, however once you try running the jarified version of the program java throws the following error

Exception running Application:
#<TypeError: illegal access on 'addListener': Class org.jruby.javasupport.JavaMethod can not access a member of class javafx.scene.control.TextInputControl$TextProperty with modifiers "public">
org/jruby/java/proxies/JavaProxy.java:347:in `java_send'
@byteit101
Copy link
Member

@Hobogrammer do you have a small app that I can use to reproduce this?

@Hobogrammer
Copy link
Author

@byteit101 This was the code I was using in my tiny app before the work around. https://github.com/Hobogrammer/Tadoku-Character-Counter/tree/b8ff291cb4d16c0d88586f8f62856d06a3a7b127

@byteit101
Copy link
Member

I don't even see the .addChangeListener in official JavaFX docs. Where is this method coming from?

http://docs.oracle.com/javafx/2/api/javafx/beans/property/SimpleStringProperty.html

@byteit101
Copy link
Member

oh duh, its a jrubyfx method with the same name as a javafx 1 method which makes it hard to google

@edubkendo
Copy link
Member

Yeah, the actual javafx 2.0 method is just addListener, but in our dsl its add_change_listener:

https://github.com/jruby/jrubyfx/blob/master/lib/jrubyfx/core_ext/observable_value.rb#L28

@enebo
Copy link
Member

enebo commented Apr 15, 2013

For current users of jrubyfx I think things are still in enough flux where we can just change the API to match current JavaFX, but does JRubyFX even work with older JavaFX? (sorry for the aside in this report :) )

@byteit101
Copy link
Member

I don't think so, its something completely different. I just found it confusing until I realized what was going on that we (@enebo actually) called it add_change_listener to wrap addListener, and javafx 1 had addChangeListener

@enebo
Copy link
Member

enebo commented Apr 15, 2013

Perhaps there was an overload issue? I don't know why I would have added that name without following what I thought was FX naming. Hmmm I bet this was some mongo commit where I explained nothing too...

@byteit101
Copy link
Member

https://github.com/jruby/jrubyfx/blob/689a37004590ceeda7509d42bb0c6c8148903767/lib/jrubyfx/core_ext/observable_value.rb

anyway, the interesting issue is why does jarification make this fail? its just a simple wrapper

@enebo
Copy link
Member

enebo commented Apr 15, 2013

This is typically the execution environment which causes these issues. If we extend a class we cannot really extend it in the Java sense since we are not actually constructing a Java class at runtime which extends the signatures. This in turn means to access protected methods (or package) we end up using setAccessible to make those methods execute in spite of being called from a non-extending (or non-package) Java object (our Ruby wrapped one). This is just speculation.

@Hobogrammer Can you describe the way in which you execute the jar and how you created it?

@Hobogrammer
Copy link
Author

Sorry about the delay.

simply used jrubyfx-jarify /projects/JavaFX/Tadoku-Character-Counter/src --main /projects/JavaFX/Tadoku-Character-Counter/src/charcount.rb TCC.jar to build the jar and java -jar TCC.jar to run it.

@byteit101
Copy link
Member

I think this is actually a bug in JRuby as I was modifying this stuff, and the following happened:

  • direct calling add_listener works but gives off warning
  • using java_send throws odd access permission
  • using java_method calls wrong method but no errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants