JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-4105

Rubyspec: SimpleDelegator send spec fails due to bug in 1.8.7 stdlib

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.4.0RC1
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: Ruby 1.8.7, RubySpec
    • Labels:
      None
    • Number of attachments :
      0

      Description

      I believe we inherited this via 1.8.7's stdlib:

      1)
      SimpleDelegator.new forwards private method calls made via send or __send__ ERROR
      NoMethodError: undefined method `priv' for #<DelegateSpecs::Simple:0x3a1778>
      /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:157:in `method_missing'
      /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:21
      /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:5
      /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:55:in `load'
      

        Issue Links

          Activity

          Hide
          Charles Oliver Nutter added a comment -

          Two more:

               [java] 4)
               [java] SimpleDelegator when frozen is not writeable FAILED
               [java] Expected RuntimeError but no exception was raised
               [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:22
               [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4
               [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:55:in `load'
               [java] 
               [java] 5)
               [java] SimpleDelegator when frozen creates a frozen clone ERROR
               [java] TypeError: can't modify frozen 
               [java] /Users/headius/projects/jruby/spec/../lib/ruby/1.8/delegate.rb:225:in `__setobj__'
               [java] /Users/headius/projects/jruby/spec/../lib/ruby/1.8/delegate.rb:231:in `clone'
               [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:26
               [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4
               [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:55:in `load'
          
          Show
          Charles Oliver Nutter added a comment - Two more: [java] 4) [java] SimpleDelegator when frozen is not writeable FAILED [java] Expected RuntimeError but no exception was raised [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:22 [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4 [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:55:in `load' [java] [java] 5) [java] SimpleDelegator when frozen creates a frozen clone ERROR [java] TypeError: can't modify frozen [java] /Users/headius/projects/jruby/spec/../lib/ruby/1.8/delegate.rb:225:in `__setobj__' [java] /Users/headius/projects/jruby/spec/../lib/ruby/1.8/delegate.rb:231:in `clone' [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:26 [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4 [java] /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:55:in `load'
          Hide
          Charles Oliver Nutter added a comment -

          I'm co-opting this issue for all delegate issues, including some related to my pure-Java replacement for Delegator.

          Currently the pure-Java version fails 6 specs:

          1)
          SimpleDelegator when frozen is not writeable FAILED
          Expected RuntimeError but no exception was raised
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:22
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:56:in `load'
          
          2)
          SimpleDelegator when frozen creates a frozen clone ERROR
          TypeError: can't modify frozen 
          /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:232:in `__setobj__'
          /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:238:in `clone'
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:26
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:56:in `load'
          
          3)
          SimpleDelegator can be marshalled with its instance variables intact FAILED
          Expected nil
           to equal "bar"
          
          /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:20
          /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:4
          /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:56:in `load'
          
          4)
          SimpleDelegator#method returns a method object for a valid method ERROR
          NameError: undefined method `pub' for class `SimpleDelegator'
          /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:12
          /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:5
          /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:56:in `load'
          
          5)
          SimpleDelegator#method raises a NameError if method is no longer valid because object has changed ERROR
          NameError: undefined method `pub' for class `SimpleDelegator'
          /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:32
          /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:5
          /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:56:in `load'
          
          6)
          SimpleDelegator.new forwards private method calls made via send or __send__ ERROR
          NoMethodError: method `priv' is private
          /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:23
          /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:5
          /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:56:in `load'
          

          However, even without my Java version, we're failing 4 specs:

          1)
          SimpleDelegator when frozen is not writeable FAILED
          Expected RuntimeError but no exception was raised
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:22
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:56:in `load'
          
          2)
          SimpleDelegator when frozen creates a frozen clone ERROR
          TypeError: can't modify frozen 
          /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:239:in `__setobj__'
          /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:245:in `clone'
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:26
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4
          /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:56:in `load'
          
          3)
          SimpleDelegator can be marshalled with its instance variables intact FAILED
          Expected nil
           to equal "bar"
          
          /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:20
          /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:4
          /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:56:in `load'
          
          4)
          SimpleDelegator.new forwards private method calls made via send or __send__ ERROR
          NoMethodError: undefined method `priv' for #<DelegateSpecs::Simple:0xb6a6d6>
          /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:171:in `method_missing'
          /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:22
          /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:5
          /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:56:in `load'
          

          So there's something larger at play here. In any case, we should try to get these all passing without re-introducing the super-slow version of Delegator.

          My first attempt to do this without the java impl was to cache a module per incoming class, so that the eval'ed method definitions are only done once, and then extending that onto each object delegated to. It's not great, however, since it uses extend. What's really needed here is a fast way to define these methods directly on the object.

          Show
          Charles Oliver Nutter added a comment - I'm co-opting this issue for all delegate issues, including some related to my pure-Java replacement for Delegator. Currently the pure-Java version fails 6 specs: 1) SimpleDelegator when frozen is not writeable FAILED Expected RuntimeError but no exception was raised /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:22 /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4 /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:56:in `load' 2) SimpleDelegator when frozen creates a frozen clone ERROR TypeError: can't modify frozen /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:232:in `__setobj__' /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:238:in `clone' /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:26 /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4 /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:56:in `load' 3) SimpleDelegator can be marshalled with its instance variables intact FAILED Expected nil to equal "bar" /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:20 /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:4 /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:56:in `load' 4) SimpleDelegator#method returns a method object for a valid method ERROR NameError: undefined method `pub' for class `SimpleDelegator' /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:12 /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:5 /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:56:in `load' 5) SimpleDelegator#method raises a NameError if method is no longer valid because object has changed ERROR NameError: undefined method `pub' for class `SimpleDelegator' /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:32 /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:5 /Users/headius/projects/jruby/spec/ruby/library/delegate/method_spec.rb:56:in `load' 6) SimpleDelegator.new forwards private method calls made via send or __send__ ERROR NoMethodError: method `priv' is private /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:23 /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:5 /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:56:in `load' However, even without my Java version, we're failing 4 specs: 1) SimpleDelegator when frozen is not writeable FAILED Expected RuntimeError but no exception was raised /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:22 /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4 /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:56:in `load' 2) SimpleDelegator when frozen creates a frozen clone ERROR TypeError: can't modify frozen /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:239:in `__setobj__' /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:245:in `clone' /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:26 /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:4 /Users/headius/projects/jruby/spec/ruby/library/delegate/frozen_spec.rb:56:in `load' 3) SimpleDelegator can be marshalled with its instance variables intact FAILED Expected nil to equal "bar" /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:20 /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:4 /Users/headius/projects/jruby/spec/ruby/library/delegate/marshal_spec.rb:56:in `load' 4) SimpleDelegator.new forwards private method calls made via send or __send__ ERROR NoMethodError: undefined method `priv' for #<DelegateSpecs::Simple:0xb6a6d6> /Users/headius/projects/jruby/lib/ruby/1.8/delegate.rb:171:in `method_missing' /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:22 /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:5 /Users/headius/projects/jruby/spec/ruby/library/delegate/send_spec.rb:56:in `load' So there's something larger at play here. In any case, we should try to get these all passing without re-introducing the super-slow version of Delegator. My first attempt to do this without the java impl was to cache a module per incoming class, so that the eval'ed method definitions are only done once, and then extending that onto each object delegated to. It's not great, however, since it uses extend. What's really needed here is a fast way to define these methods directly on the object.
          Hide
          Charles Oliver Nutter added a comment -

          I've fixed the new regressions in 81672e5, but I'm not confident that the new java-based Delegator is "perfect" just yet.

          Show
          Charles Oliver Nutter added a comment - I've fixed the new regressions in 81672e5, but I'm not confident that the new java-based Delegator is "perfect" just yet.
          Hide
          Vladimir Sizikov added a comment -

          Actually, one "new" regression is still there:

          3)
          SimpleDelegator can be marshalled with its instance variables intact FAILED
          Expected nil
           to equal "bar"
          
          D:/work/jruby-dev/rubyspec.git/library/delegate/marshal_spec.rb:20
          D:/work/jruby-dev/rubyspec.git/library/delegate/marshal_spec.rb:4
          D:/work/jruby-dev/rubyspec.git/library/delegate/marshal_spec.rb:56:in `load'
          

          It was passing before the following commit:

          d372c3c More tweaks for native Delegator impl.
          
          Show
          Vladimir Sizikov added a comment - Actually, one "new" regression is still there: 3) SimpleDelegator can be marshalled with its instance variables intact FAILED Expected nil to equal "bar" D:/work/jruby-dev/rubyspec.git/library/delegate/marshal_spec.rb:20 D:/work/jruby-dev/rubyspec.git/library/delegate/marshal_spec.rb:4 D:/work/jruby-dev/rubyspec.git/library/delegate/marshal_spec.rb:56:in `load' It was passing before the following commit: d372c3c More tweaks for native Delegator impl.
          Hide
          Charles Oliver Nutter added a comment -

          I reverted to a pure-ruby delegator, with a flag to turn on the native one. But it's a cleaned-up delegator that caches modules full of all the methods it used to eval every time. It appears to pass all specs and introduces no other issues.

          So we should be back to just the original set of failures, which came along with Ruby's stdlib delegate.rb. Bumping off 1.5.

          Show
          Charles Oliver Nutter added a comment - I reverted to a pure-ruby delegator, with a flag to turn on the native one. But it's a cleaned-up delegator that caches modules full of all the methods it used to eval every time. It appears to pass all specs and introduces no other issues. So we should be back to just the original set of failures, which came along with Ruby's stdlib delegate.rb. Bumping off 1.5.
          Hide
          Hiro Asari added a comment -

          How is this a blocker if it's stdlib bug? Of the four failing specs, three ('marshal' and 'frozen' ones) are still not fixed in the 1.8 branch; unless they're backported to 1.8, we are not going to see the fix. (Are we?)

          The last one (the 'send' one) is not a bug (see http://redmine.ruby-lang.org/issues/show/2206), so I tweaked the spec itself (http://github.com/rubyspec/rubyspec/commit/892080e2b0a7c870df48720118b464f712393dad).

          Show
          Hiro Asari added a comment - How is this a blocker if it's stdlib bug? Of the four failing specs, three ('marshal' and 'frozen' ones) are still not fixed in the 1.8 branch; unless they're backported to 1.8, we are not going to see the fix. (Are we?) The last one (the 'send' one) is not a bug (see http://redmine.ruby-lang.org/issues/show/2206 ), so I tweaked the spec itself ( http://github.com/rubyspec/rubyspec/commit/892080e2b0a7c870df48720118b464f712393dad ).
          Hide
          Hiro Asari added a comment -

          I think this one is fixed in the master now. I removed the last tag at 23030b0.

          Show
          Hiro Asari added a comment - I think this one is fixed in the master now. I removed the last tag at 23030b0.
          Hide
          Hiro Asari added a comment -

          Still failing in Compiled mode.

          Show
          Hiro Asari added a comment - Still failing in Compiled mode.
          Hide
          Hiro Asari added a comment -

          The specs are passing in the compile mode now for delegate/delegator/send_spec.rb. There are new specs failing for both interpreted and compiled modes. However, the policy regarding RubySepc has changed, so I'm resolving this ticket as "fixed".

          Show
          Hiro Asari added a comment - The specs are passing in the compile mode now for delegate/delegator/send_spec.rb . There are new specs failing for both interpreted and compiled modes. However, the policy regarding RubySepc has changed, so I'm resolving this ticket as "fixed".

            People

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

              Dates

              • Created:
                Updated:
                Resolved: