{"action":"created","issue":{"url":"https://api.github.com/repos/jruby/jruby/issues/3105","repository_url":"https://api.github.com/repos/jruby/jruby","labels_url":"https://api.github.com/repos/jruby/jruby/issues/3105/labels{/name}","comments_url":"https://api.github.com/repos/jruby/jruby/issues/3105/comments","events_url":"https://api.github.com/repos/jruby/jruby/issues/3105/events","html_url":"https://github.com/jruby/jruby/issues/3105","id":93146853,"number":3105,"title":"Java Integration conversions","user":{"login":"InfraRuby","id":6770276,"avatar_url":"https://avatars.githubusercontent.com/u/6770276?v=3","gravatar_id":"","url":"https://api.github.com/users/InfraRuby","html_url":"https://github.com/InfraRuby","followers_url":"https://api.github.com/users/InfraRuby/followers","following_url":"https://api.github.com/users/InfraRuby/following{/other_user}","gists_url":"https://api.github.com/users/InfraRuby/gists{/gist_id}","starred_url":"https://api.github.com/users/InfraRuby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/InfraRuby/subscriptions","organizations_url":"https://api.github.com/users/InfraRuby/orgs","repos_url":"https://api.github.com/users/InfraRuby/repos","events_url":"https://api.github.com/users/InfraRuby/events{/privacy}","received_events_url":"https://api.github.com/users/InfraRuby/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-05T21:03:02Z","updated_at":"2016-03-16T21:41:53Z","closed_at":"2016-03-16T21:41:53Z","body":"Java Integration converts `java.lang.String` <-> `String` and `java.math.BigInteger` <-> `Integer`.\r\n\r\nThese conversions violate Java and Ruby conventions for object identity:\r\n\r\n    a_string = \"a ruby string\"\r\n    Java::java.lang.System.identityHashCode(a_string) == Java::java.lang.System.identityHashCode(a_string) # => false\r\n\r\n    map = Java::java.util.IdentityHashMap.new\r\n    key = \"a ruby string\"\r\n    map.put(key, \"value\")\r\n    map.get(key) # => nil\r\n\r\n    m = Java::java.lang.Object[1].new\r\n    m[0] = \"a ruby string\"\r\n    m[0].equal?(m[0]) # => false\r\n\r\nThese conversions break some methods:\r\n\r\n    a_fixnum = 17\r\n    Java::java.math.BigInteger.valueOf(a_fixnum).class # => Bignum\r\n\r\nThese conversions lose information:\r\n\r\n    m = Java::java.lang.Object[2].new\r\n    m[0] = \"a ruby string\"\r\n    m[1] = \"a java string\".to_java\r\n    m[0].class # => String\r\n    m[1].class # => String\r\n\r\n    m = Java::java.lang.Object[2].new\r\n    m[0] = \"a ruby string in utf-8\"\r\n    m[1] = \"a ruby string in us-ascii\".force_encoding(Encoding::US_ASCII)\r\n    m[0].encoding # => Encoding::UTF_8\r\n    m[1].encoding # => Encoding::UTF_8\r\n\r\nWould you consider a patch to disable these conversions on a per-source-file basis?\r\n"},"comment":{"url":"https://api.github.com/repos/jruby/jruby/issues/comments/197559994","html_url":"https://github.com/jruby/jruby/issues/3105#issuecomment-197559994","issue_url":"https://api.github.com/repos/jruby/jruby/issues/3105","id":197559994,"user":{"login":"InfraRuby","id":6770276,"avatar_url":"https://avatars.githubusercontent.com/u/6770276?v=3","gravatar_id":"","url":"https://api.github.com/users/InfraRuby","html_url":"https://github.com/InfraRuby","followers_url":"https://api.github.com/users/InfraRuby/followers","following_url":"https://api.github.com/users/InfraRuby/following{/other_user}","gists_url":"https://api.github.com/users/InfraRuby/gists{/gist_id}","starred_url":"https://api.github.com/users/InfraRuby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/InfraRuby/subscriptions","organizations_url":"https://api.github.com/users/InfraRuby/orgs","repos_url":"https://api.github.com/users/InfraRuby/repos","events_url":"https://api.github.com/users/InfraRuby/events{/privacy}","received_events_url":"https://api.github.com/users/InfraRuby/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T21:41:53Z","updated_at":"2016-03-16T21:41:53Z","body":"@headius I'm closing this issue as another approach is possible, with a JRuby extension: the `infraruby-java` gem (MIT license) adds `JAVA`, which is similar to `Java` in JRuby, but without those conversions.\r\n\r\nThanks for JRuby; your work is excellent!\r\n"}}