[Probably a question, but perhaps also a possibility for improvement] Getting method(:foobar).source_location to work? #8440
rubyFeedback
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
So I am still extending my java-swing and jruby foobar.
In ruby I am quite used to this:
To my (slight) surprise this does not seem to work in jruby-swing:
I was trying to find out what parameters mouseEnter would need, and
I did not know where it was defined.
To my surprise, jruby did not show where the source location is defined.
But, even stranger ... jruby seems to completely be silent about it. Actually
it will just return nil.
Now ... I assume that it may not be trivial to get the information where the
source is, as it is java, and perhaps there is a lack of cross-information between
java code and ruby code. But I believe that returning nil here is still wrong.
I can kind of understand the rationale, and if that method can not be made
better, then I guess nil is the most sensible default return value - but when I
used it, I was surprised that nothing seemed to happen at all. This is very
different to default MRI behaviour, in my opinion. Granted, now that I know
about this it is not so bad, but initially I thought I had a bug in my code.
Of course the best solution would be to show the java-source code or path,
though perhaps that can not be made available.
The method exists, and I can verify this when I pass a wrong number of arguments to it:
^^^^
(I am actually trying to find documentation for the API there, for jruby.)
Anyway - I'll close this to keep the bug tracker clean and there is probably not a simple solution. It is just surprising that the source location was not returned, but the method still may exist and also cause exceptions.
Beta Was this translation helpful? Give feedback.
All reactions