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

Class name misreported for certain instantiations of Proc objects

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.5.1
    • Fix Version/s: JRuby 1.6RC1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Mac OS X 10.6.4 Intel
    • Number of attachments :
      0

      Description

      I have found a bug that seems to affect the reported class name on instantiated custom Proc objects.

      Depending on how the object is instantiated, JRuby will report the object's class name as either the direct class that was instantiated or as the parent Proc class. Here's some example code to reproduce the issue:

      module Adhearsion
        class Foo
      
          def self.new_bar(&block)
            Bar.new(&block)
          end
      
          class Bar < Proc
            def initialize(&block)
              super(&block)
            end
          end
        end
      end
      

      With the above code I tried two different ways of getting a Adhearsion::Foo::Bar object:

      x = Adhearsion::Foo::Bar.new { puts "x" }
      puts x.class # => Adhearsion::Foo::Bar
      
      x = Adhearsion::Foo.new_bar { puts "x" }
      puts x.class # => Proc
      

      Under Ruby MRI 1.8.7 both "puts x.class" return "Adhearsion::Foo::Bar". Under JRuby the second call returns "Proc". This interferes with type checking that we are using in our framework when run under Adhearsion.

      In case you need more information, the original problem report is here:
      https://adhearsion.lighthouseapp.com/projects/5871-adhearsion/tickets/92-menu-method-under-jruby-does-not-appear-to-work

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Wow...weird one. Looking into it.

        Show
        Charles Oliver Nutter added a comment - Wow...weird one. Looking into it.
        Hide
        Charles Oliver Nutter added a comment -

        Ok, this case isn't just mireporting the class name, it's actually not instantiating the subclass.

        It appears that our logic isn't quite right. If the block passed in already has had a Proc attacahed to it, we're using that automatically. We should only do that if it's an implicit block in the current call.

        I have a fix and spec in the works.

        Show
        Charles Oliver Nutter added a comment - Ok, this case isn't just mireporting the class name, it's actually not instantiating the subclass. It appears that our logic isn't quite right. If the block passed in already has had a Proc attacahed to it, we're using that automatically. We should only do that if it's an implicit block in the current call. I have a fix and spec in the works.
        Hide
        Charles Oliver Nutter added a comment -

        Fix and spec pushed in a5a4e3e.

        Show
        Charles Oliver Nutter added a comment - Fix and spec pushed in a5a4e3e.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: