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
        Charles Oliver Nutter added a comment -

        Only affects 1.6 branch. I made it match master.

        commit 0eaea39c52720c9599eb9f35efcc0ffdbb4aa45c
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Wed Jan 25 15:02:23 2012 -0600
        
            Fix bad renaming logic for Scala names.
        
        diff --git a/src/org/jruby/javasupport/JavaClass.java b/src/org/jruby/javasupport/JavaClass.java
        index 5a6c925..00f7a6c 100644
        --- a/src/org/jruby/javasupport/JavaClass.java
        +++ b/src/org/jruby/javasupport/JavaClass.java
        @@ -913,11 +913,12 @@ public class JavaClass extends JavaObject {
             }
         
             private static String fixScalaNames(String name) {
        +        String s = name;
                 for (Map.Entry<String, String> entry : SCALA_OPERATORS.entrySet()) {
        -            name.replaceAll(entry.getKey(), entry.getValue());
        +            s = s.replaceAll(entry.getKey(), entry.getValue());
                 }
         
        -        return name;
        +        return s;
             }
         
             private static final Map<String, String> SCALA_OPERATORS;
        
        Show
        Charles Oliver Nutter added a comment - Only affects 1.6 branch. I made it match master. commit 0eaea39c52720c9599eb9f35efcc0ffdbb4aa45c Author: Charles Oliver Nutter <headius@headius.com> Date: Wed Jan 25 15:02:23 2012 -0600 Fix bad renaming logic for Scala names. diff --git a/src/org/jruby/javasupport/JavaClass.java b/src/org/jruby/javasupport/JavaClass.java index 5a6c925..00f7a6c 100644 --- a/src/org/jruby/javasupport/JavaClass.java +++ b/src/org/jruby/javasupport/JavaClass.java @@ -913,11 +913,12 @@ public class JavaClass extends JavaObject { } private static String fixScalaNames(String name) { + String s = name; for (Map.Entry<String, String> entry : SCALA_OPERATORS.entrySet()) { - name.replaceAll(entry.getKey(), entry.getValue()); + s = s.replaceAll(entry.getKey(), entry.getValue()); } - return name; + return s; } private static final Map<String, String> SCALA_OPERATORS;
        Hide
        Charles Oliver Nutter added a comment -

        Looks like this was also my mistake, and it didn't show up until Hiro added a test for the behavior.

        commit 975725556f2c9f76263d5b3452d8d52096ba05dd
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Tue Jan 18 00:33:11 2011 -0600
        
            Fix my breakage of Scala method name de-mangling.
        
        diff --git a/src/org/jruby/javasupport/JavaClass.java b/src/org/jruby/javasupport/JavaClass.java
        index ab532e4..e396ea6 100644
        --- a/src/org/jruby/javasupport/JavaClass.java
        +++ b/src/org/jruby/javasupport/JavaClass.java
        @@ -905,48 +905,35 @@ public class JavaClass extends JavaObject {
             }
         
             private static String fixScalaNames(String name) {
        -        Matcher m = SCALA_OPERATOR_PATTERN.matcher(name);
        -        m.find();
        -        if (m.matches()) {
        -            return SCALA_OPERATORS.get(m.group(1));
        +        for (Map.Entry<String, String> entry : SCALA_OPERATORS.entrySet()) {
        +            name.replaceAll(entry.getKey(), entry.getValue());
                 }
         
                 return name;
             }
        ...
        
        Show
        Charles Oliver Nutter added a comment - Looks like this was also my mistake, and it didn't show up until Hiro added a test for the behavior. commit 975725556f2c9f76263d5b3452d8d52096ba05dd Author: Charles Oliver Nutter <headius@headius.com> Date: Tue Jan 18 00:33:11 2011 -0600 Fix my breakage of Scala method name de-mangling. diff --git a/src/org/jruby/javasupport/JavaClass.java b/src/org/jruby/javasupport/JavaClass.java index ab532e4..e396ea6 100644 --- a/src/org/jruby/javasupport/JavaClass.java +++ b/src/org/jruby/javasupport/JavaClass.java @@ -905,48 +905,35 @@ public class JavaClass extends JavaObject { } private static String fixScalaNames(String name) { - Matcher m = SCALA_OPERATOR_PATTERN.matcher(name); - m.find(); - if (m.matches()) { - return SCALA_OPERATORS.get(m.group(1)); + for (Map.Entry<String, String> entry : SCALA_OPERATORS.entrySet()) { + name.replaceAll(entry.getKey(), entry.getValue()); } return name; } ...
        Hide
        Charles Oliver Nutter added a comment -

        Arturas says it's still broken on jruby-1_6. Investigating.

        Show
        Charles Oliver Nutter added a comment - Arturas says it's still broken on jruby-1_6. Investigating.
        Hide
        Charles Oliver Nutter added a comment -

        Jeez. Ok.

        So that commit I posted above was well before the JRuby 1.6.0 release, which means we haven't been properly translating the Scala names like we intended since then. So I botched that real good. The original intention was to have all those names translated to their symbolic form.

        The right fix now would be to add the symbolic names as aliases for the other names. It was intended by the original code (from David Pollack) that you'd never see the $ names, but I think that goes against our way too. So I'll modify it to have both names from now on.

        Funny thing...we fixed the Scala name translation because it was broken, but you depend on the broken behavior. And then it turns out that both names should be there. Quirky.

        Show
        Charles Oliver Nutter added a comment - Jeez. Ok. So that commit I posted above was well before the JRuby 1.6.0 release, which means we haven't been properly translating the Scala names like we intended since then. So I botched that real good. The original intention was to have all those names translated to their symbolic form. The right fix now would be to add the symbolic names as aliases for the other names. It was intended by the original code (from David Pollack) that you'd never see the $ names, but I think that goes against our way too. So I'll modify it to have both names from now on. Funny thing...we fixed the Scala name translation because it was broken, but you depend on the broken behavior. And then it turns out that both names should be there. Quirky.
        Hide
        Charles Oliver Nutter added a comment -

        Oh, for what it's worth, once this is fixed, you can just do scala_obj + scala_obj rather than using send for the method names that are valid in Ruby. I'll document those when I write up a complete test for this functionality.

        In my defense, I did ask David Pollack to provide test cases for his changes. He never did

        Show
        Charles Oliver Nutter added a comment - Oh, for what it's worth, once this is fixed, you can just do scala_obj + scala_obj rather than using send for the method names that are valid in Ruby. I'll document those when I write up a complete test for this functionality. In my defense, I did ask David Pollack to provide test cases for his changes. He never did
        Hide
        Arturas Slajus added a comment -

        Well, `a = 3` on ruby invokes `a = a + 3` while on Scala it literally invokes `a.=(3)`.

        So we still need to `a.send(:"+=", 3)`...

        Show
        Arturas Slajus added a comment - Well, `a = 3` on ruby invokes `a = a + 3` while on Scala it literally invokes `a. =(3)`. So we still need to `a.send(:"+=", 3)`...
        Hide
        Arturas Slajus added a comment -

        gosh, i hate jira...

        Show
        Arturas Slajus added a comment - gosh, i hate jira...
        Hide
        Charles Oliver Nutter added a comment - - edited

        Yes, += is not a method call in Ruby, and is expanded to a = a + b. I will document all the cases that are value method call names, and outside that you'll have to send. Scala obviously has much more flexible method/operator naming we can't fully match.

        Show
        Charles Oliver Nutter added a comment - - edited Yes, += is not a method call in Ruby, and is expanded to a = a + b. I will document all the cases that are value method call names, and outside that you'll have to send. Scala obviously has much more flexible method/operator naming we can't fully match.
        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: