Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.7
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
      Mac OS X Lion
    • Number of attachments :
      0

      Description

      class WorkerGroup < ThreadGroup
        def initialize(a,b,c)
          @args=[a,b,c]
        end
      end
      
      WorkerGroup.new(1,2,3)  # => raises ArgumentError
      WorkerGroup.method(:new).arity  # => 0 (should be -1)
      

      Workaround:

      # redefine new
      def self.new(*args)
        tg = super()
        tg.send(:initialize, *args)
        tg
      end
      

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Oh, interesting. I'll have a look.

        Show
        Charles Oliver Nutter added a comment - Oh, interesting. I'll have a look.
        Hide
        Charles Oliver Nutter added a comment -

        Easy one!

        commit 010207e77252c2bc2da311ac360b0e3eac4a607f
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Fri Jun 29 10:21:49 2012 -0500
        
            Fix JRUBY-6722
            
            Can't instantiate ThreadGroup subclass with arguments
            
            We had defined 'new' on ThreadGroup, when what we needed was an
            ObjectAllocator for the normal 'new' logic to work. With that fix,
            subclass initialize methods work fine.
        
        Show
        Charles Oliver Nutter added a comment - Easy one! commit 010207e77252c2bc2da311ac360b0e3eac4a607f Author: Charles Oliver Nutter <headius@headius.com> Date: Fri Jun 29 10:21:49 2012 -0500 Fix JRUBY-6722 Can't instantiate ThreadGroup subclass with arguments We had defined 'new' on ThreadGroup, when what we needed was an ObjectAllocator for the normal 'new' logic to work. With that fix, subclass initialize methods work fine.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: