Details

    • Number of attachments :
      0

      Description

      arturas@zeus:~/work/spacegame/server$ . .rvmrc
      Using /home/arturas/.rvm/gems/jruby-1.6.5 with gemset nebulaserver
      arturas@zeus:~/work/spacegame/server$ rake db:load --trace
      ** Invoke db:load (first_time)
      ** Execute db:load
      ** Invoke snapshot:load (first_time)
      ** Invoke environment (first_time)
      ** Execute environment
      ** Execute snapshot:load
      Loading DB from /home/arturas/work/spacegame/server/db/snapshots/main.sql...
      Done.
      Cloning database schema to test.
      ** Invoke db:test:clone (first_time)
      ** Invoke environment 
      ** Execute db:test:clone
      arturas@zeus:~/work/spacegame/server$ rvm use jruby-head-n166
      Using /home/arturas/.rvm/gems/jruby-head-n166
      arturas@zeus:~/work/spacegame/server$ rake db:load --trace
      ** Invoke db:load (first_time)
      ** Execute db:load
      ** Invoke snapshot:load (first_time)
      ** Invoke environment (first_time)
      ** Execute environment
      rake aborted!
      undefined method `$plus$eq' for #<Java::ScalaCollectionMutable::ArrayBuffer:0x19ee400>
      org/jruby/RubyKernel.java:2078:in `send'
      /home/arturas/work/spacegame/server/lib/initializer.rb:344:in `to_scala'
      org/jruby/RubyArray.java:1614:in `each'
      /home/arturas/work/spacegame/server/lib/initializer.rb:344:in `to_scala'
      /home/arturas/work/spacegame/server/lib/initializer.rb:335:in `to_scala'
      org/jruby/RubyHash.java:1181:in `each'
      /home/arturas/work/spacegame/server/lib/initializer.rb:334:in `to_scala'
      /home/arturas/work/spacegame/server/lib/initializer.rb:335:in `to_scala'
      org/jruby/RubyHash.java:1181:in `each'
      /home/arturas/work/spacegame/server/lib/initializer.rb:334:in `to_scala'
      /home/arturas/work/spacegame/server/lib/app/classes/space_mule.rb:82:in `send_config'
      /home/arturas/work/spacegame/server/lib/server/game_logger.rb:119:in `suppress'
      /home/arturas/work/spacegame/server/lib/app/classes/space_mule.rb:81:in `send_config'
      /home/arturas/work/spacegame/server/lib/app/classes/space_mule.rb:71:in `initialize_mule'
      /home/arturas/work/spacegame/server/lib/server/game_logger.rb:76:in `block'
      /home/arturas/work/spacegame/server/lib/app/classes/space_mule.rb:70:in `initialize_mule'
      /home/arturas/work/spacegame/server/lib/app/classes/space_mule.rb:14:in `initialize'
      /home/arturas/.rvm/rubies/jruby-head-n166/lib/ruby/1.8/singleton.rb:109:in `instance'
      /home/arturas/.rvm/rubies/jruby-head-n166/lib/ruby/1.8/singleton.rb:107:in `instance'
      /home/arturas/work/spacegame/server/lib/initializer.rb:389:in `(root)'
      org/jruby/RubyProc.java:270:in `call'
      org/jruby/RubyProc.java:220:in `call'
      /home/arturas/work/spacegame/server/lib/initializer.rb:320:in `(root)'
      org/jruby/RubyKernel.java:1027:in `require'
      /home/arturas/work/spacegame/server/lib/initializer.rb:36:in `require'
      /home/arturas/work/spacegame/server/Rakefile:29:in `(root)'
      org/jruby/RubyProc.java:270:in `call'
      org/jruby/RubyProc.java:220:in `call'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
      org/jruby/RubyArray.java:1614:in `each'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
      /home/arturas/.rvm/rubies/jruby-head-n166/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `invoke_prerequisites'
      org/jruby/RubyArray.java:1614:in `each'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `invoke_with_call_chain'
      /home/arturas/.rvm/rubies/jruby-head-n166/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
      /home/arturas/work/spacegame/server/tasks/db.rake:140:in `(root)'
      org/jruby/RubyProc.java:270:in `call'
      org/jruby/RubyProc.java:220:in `call'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
      org/jruby/RubyArray.java:1614:in `each'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
      /home/arturas/.rvm/rubies/jruby-head-n166/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
      org/jruby/RubyArray.java:1614:in `each'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
      /home/arturas/.rvm/gems/jruby-head-n166/gems/rake-0.9.2.2/bin/rake:33:in `(root)'
      org/jruby/RubyKernel.java:1052:in `load'
      /home/arturas/.rvm/gems/jruby-head-n166/bin/rake:19:in `(root)'
      Tasks: TOP => snapshot:load => environment
      
      class Object
          def to_scala
            case self
            when Hash
              scala_hash = Java::scala.collection.immutable.HashMap.new
              each do |key, value|
                scala_hash = scala_hash.updated(key.to_scala, value.to_scala)
              end
              scala_hash
            when Set
              scala_set = Java::scala.collection.immutable.HashSet.new
              each { |item| scala_set = scala_set.send(:"$plus", item.to_scala) }
              scala_set
            when Array
              scala_array = Java::scala.collection.mutable.ArrayBuffer.new
              each { |value| scala_array.send(:"$plus$eq", value.to_scala) } # It goes BOOM here.
              scala_array.to_indexed_seq
            when Symbol
              to_s
            else
              self
            end
          end
      

        Activity

        Hide
        Arturas Slajus added a comment -

        Anyway, I'm resorting to:

          # Scala <-> Ruby interoperability.
          class Object
            # Support both 1.6.5 and 1.6.6.
            v1, v2, v3 = JRUBY_VERSION.split(".")[0..2].map(&:to_i)
            PLUS_EQ = v1 >= 1 && v2 >= 6 && v3 >= 6 ? :"+=" : :"$plus$eq"
        
            def to_scala
              case self
              when Hash
                scala_hash = Java::scala.collection.immutable.HashMap.new
                each do |key, value|
                  scala_hash = scala_hash.updated(key.to_scala, value.to_scala)
                end
                scala_hash
              when Set
                scala_set = Java::scala.collection.immutable.HashSet.new
                each { |item| scala_set = scala_set + item.to_scala }
                scala_set
              when Array
                scala_array = Java::scala.collection.mutable.ArrayBuffer.new
                each { |value| scala_array.send(PLUS_EQ, value.to_scala) }
                scala_array.to_indexed_seq
              when Symbol
                to_s
              else
                self
              end
            end
          end
        

        hackery right now. IMHO, the right thing to do would be to support both ways in 1.6.6, with deprecation warning when "$plus$eq" is used. AFAIK $ is not in SCALA_OPERATORS (https://github.com/jruby/jruby/blob/0eaea39c52720c9599eb9f35efcc0ffdbb4aa45c/src/org/jruby/javasupport/JavaClass.java), so a simple include match before translating method should be sufficient and wouldn't be a performance hit.

        Show
        Arturas Slajus added a comment - Anyway, I'm resorting to: # Scala <-> Ruby interoperability. class Object # Support both 1.6.5 and 1.6.6. v1, v2, v3 = JRUBY_VERSION.split(".")[0..2].map(&:to_i) PLUS_EQ = v1 >= 1 && v2 >= 6 && v3 >= 6 ? :"+=" : :"$plus$eq" def to_scala case self when Hash scala_hash = Java::scala.collection.immutable.HashMap.new each do |key, value| scala_hash = scala_hash.updated(key.to_scala, value.to_scala) end scala_hash when Set scala_set = Java::scala.collection.immutable.HashSet.new each { |item| scala_set = scala_set + item.to_scala } scala_set when Array scala_array = Java::scala.collection.mutable.ArrayBuffer.new each { |value| scala_array.send(PLUS_EQ, value.to_scala) } scala_array.to_indexed_seq when Symbol to_s else self end end end hackery right now. IMHO, the right thing to do would be to support both ways in 1.6.6, with deprecation warning when "$plus$eq" is used. AFAIK $ is not in SCALA_OPERATORS ( https://github.com/jruby/jruby/blob/0eaea39c52720c9599eb9f35efcc0ffdbb4aa45c/src/org/jruby/javasupport/JavaClass.java ), so a simple include match before translating method should be sufficient and wouldn't be a performance hit.
        Hide
        Charles Oliver Nutter added a comment -

        We will support both method names in 1.6.6 and forever after. Generally we don't just drop method names...we add aliases. The original patch by David wasn't quite right in that respect.

        Show
        Charles Oliver Nutter added a comment - We will support both method names in 1.6.6 and forever after. Generally we don't just drop method names...we add aliases. The original patch by David wasn't quite right in that respect.
        Hide
        Arturas Slajus added a comment -

        So when can I expect a commit that fixes that so I could run my spec suite against latest 1.6.6?

        Show
        Arturas Slajus added a comment - So when can I expect a commit that fixes that so I could run my spec suite against latest 1.6.6?
        Hide
        Charles Oliver Nutter added a comment -

        Master is fixed in a4bf4b8. Running tests on 1.6 branch now.

        Show
        Charles Oliver Nutter added a comment - Master is fixed in a4bf4b8. Running tests on 1.6 branch now.
        Hide
        Charles Oliver Nutter added a comment -

        And 1.6 branch is fixed in 6c0234b!

        I also added this page to the wiki...please improve it

        https://github.com/jruby/jruby/wiki/Integrating-with-Scala

        Show
        Charles Oliver Nutter added a comment - And 1.6 branch is fixed in 6c0234b! I also added this page to the wiki...please improve it https://github.com/jruby/jruby/wiki/Integrating-with-Scala

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Arturas Slajus
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: