-
-
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
java.lang.ArrayList#add automatically converts Ruby's Time to java.util.Date #2049
Comments
This still exists in 9k, this is at the least confusing to the user, I'm not sure if it's a bug or not. |
in generic cases (when the target signature is simply |
@kares Why don't you think this is a bug? Time is a pretty complex object... Consider this...
I don't think time is really a primitive, but if we're going to map it to a java object it should follow the same rule as strings and have all all method additions available when accessing it from the ruby side. |
@daicoden yes that is "ugly". but there's a bigger picture and your example is actually minor to how much value would be lost if we passed down RubyTime directly every time we see a we simply need some common ground here. that being set on Java 8 we can do much better with the new Date and Time APIs. we still need to maintain compatibility but it could work with a switch to not use legacy |
thanks for the reply @kares, my thoughts on a switch below. @enebo @kares a switch or require would work, though I would be nervous turning it on as it could break other libraries which accidently relied on the current behavior for some reason. A simple solution without breaking the API would be changing the error message for java.util.DateTime to reference an issue number. The problem with the bug is that it takes a long time to comprehend that Time is an outlier and it makes you nervous about using java collections in ruby (though that's one of the best things about jruby). Another idea and expanding on my "time is not really primitive but..." comment. The inverse would break if inserting a java.util.Date, but I think it would be better to have all the implicit conversions behave the same way. Note java.util.Integer behaves like this already.
Are there any other objects that behave like Time? If not - then my vote is make Time behave like String, Integer, Boolean, etc. |
thanks @daicoden - appreciate your idea but we were actually debating avoiding those conv in the past by duck typing Java types to seem like Ruby ones (e.g.
while Ruby's we're also considering a |
Hi,
This happens using java 7 and jruby 1.7.16. The reproduction code is:
Output:
Cheers,
The text was updated successfully, but these errors were encountered: