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

String#concat(java.lang.String) does not work #4837

Closed
ketan opened this Issue Nov 3, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@ketan
Member

ketan commented Nov 3, 2017

Environment

Provide at least:

  • jruby 9.1.13.0 (2.3.3) 2017-09-06 8e1c115 Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 [darwin-x86_64]
  • Darwin ketanpkr.local 15.6.0 Darwin Kernel Version 15.6.0: Sun Jun 4 21:43:07 PDT 2017; root:xnu-3248.70.3~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,4 Darwin

Expected Behavior

  • Given the interop between java and jruby, I should be able to String#concat a (j)ruby string with a java string. Same thing happens when using String#<<

Here is a test case to reproduce:

$ bin/jruby -e '"ruby string".concat(java.lang.String.new("java string"))'
TypeError: no implicit conversion of Java::JavaLang::String into String
  concat at org/jruby/RubyString.java:2268
  <main> at -e:1
@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Nov 9, 2017

Member

Huh, surprising we don't define to_str and friends on java.lang.String.

This works:

class java::lang::String
  alias to_str to_s
end

"foo".concat("bar".to_java(:string))
Member

headius commented Nov 9, 2017

Huh, surprising we don't define to_str and friends on java.lang.String.

This works:

class java::lang::String
  alias to_str to_s
end

"foo".concat("bar".to_java(:string))

@headius headius added this to the JRuby 9.1.15.0 milestone Nov 9, 2017

headius added a commit that referenced this issue Nov 9, 2017

headius added a commit that referenced this issue Nov 9, 2017

@headius headius closed this Nov 9, 2017

@ketan

This comment has been minimized.

Show comment
Hide comment
@ketan

ketan Nov 10, 2017

Member
Member

ketan commented Nov 10, 2017

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Nov 21, 2017

Member

@ketan This has been fixed for JRuby 9.1.15.0.

Member

headius commented Nov 21, 2017

@ketan This has been fixed for JRuby 9.1.15.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment