Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JRuby 1.4
-
Component/s: Java Integration
-
Labels:None
-
Number of attachments :
Description
When calling methods in java from jruby where the same method has multiple signatures, it would be useful to have a way to pass a "typed" null object.
For example if I have 2 methods in java:
doSomething(Frame f, int i)
doSomething(Component c, int i)
and I want to make sure I call the second method but with a null component then in java I do this:
obj.doSomething((Component)null, 0)
But in jruby I haven't found a convinient way to do this. My current solution is to use reflection something like this:
method = obj.java_class.declared_method(:doSomething, Component, int)
method.invoke( obj, Java.primitive_to_java(nil), 0 )
If instead there was something like a null method on wrapped java classes this would be much nicer:
obj.doSomething(Component.null, 0)
The null method could return an special object that the jruby Java method finding code could use to find the correct method in java.
Issue Links
- duplicates
-
JRUBY-558
Integration method matching needs more help with nulls
-
Activity
| Field | Original Value | New Value |
|---|---|---|
| Priority | Major [ 3 ] | Blocker [ 1 ] |
| Fix Version/s | JRuby 1.4 [ 15285 ] |
| Attachment | jruby-3865.patch [ 44184 ] |
| Fix Version/s | JRuby 1.4 [ 15285 ] | |
| Fix Version/s | JRuby 1.x+ [ 13421 ] |
| Attachment | jruby-3865-jtg.patch [ 46795 ] |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Assignee | Charles Oliver Nutter [ headius ] | |
| Fix Version/s | JRuby 1.4 [ 15285 ] | |
| Fix Version/s | JRuby 1.x+ [ 13421 ] | |
| Resolution | Fixed [ 1 ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Ok, now this is a real need for sure, and one I've known we would hear about eventually.
Your reflection workaround is clever, and probably the only way at the moment. It is obviously less than desirable.
I think this bug may lead the way toward a practical casting syntax/API we can use for Java integration. I'm marking this a blocker for 1.4.