-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Problems calling getValue on Action object #1654
Comments
Try reference Action.NAME with Action::NAME in the ruby code instead. |
I have no problem getting the action constants (although it looks wrong, now that you mention it). I've tried calling getValue with the appropriate strings hard-coded. It's the getValue call that isn't working. |
Maybe this? TransferHandler.cut_action.value(Action::NAME) I have no clue really, I bet someone who actually knows will come by soon =) |
I've been tinkering with this a bit on JRuby 9k and I can't for the life of me figure out why the
|
I think this is a problem with how JI works and how the underlying Swing code is written. I find this to be a primal limitation of our automatic coercion so it is not something we can actually fix. I will mark as WONTFIX, but I will show you how to work around this and why it is happening. We can see that this code is weird. Namely: 'key == NAME'. In JRuby, we convert between Java <-> Ruby string types. When we get the value of NAME we convert to a Ruby String and then when we call getValue we convert it back to a Java String. Since it is a new Java String then Java object identity fails and it returns null. The good news is when people use Java Object identity with Strings they also tend to intern() the string value. So you can make all this work by intern'ing your string: name = TransferHandler.getCutAction.getValue(Action::NAME.intern) Things will work. I wonder why they did not use .equals() in this code since this could not possibly be a hot path in Swing? |
@enebo this wasn't my ticket but I definitely appreciate you dropping some knowledge on us :) |
@rtyler your excellent triaging and pondering what was wrong had me dig in. So thanks for updating the issue. This one was quite old :) |
Thanks all for the answers and information! |
I can't figure out what I'm doing wrong here. The Java code works. All the Ruby permutations fail. How can I get the values I want?
EDIT: Conversation on [jruby-user] on 8 Apr 2014 confirms this is a JRuby bug.
deleteme.java:
Results from running deleteme.java:
Now the ruby code in deleteme.rb:
Results of running deleteme.rb:
The text was updated successfully, but these errors were encountered: