"defined super" causes NullPointerException in mixins
-----------------------------------------------------

                 Key: JRUBY-5025
                 URL: http://jira.codehaus.org/browse/JRUBY-5025
             Project: JRuby
          Issue Type: Bug
          Components: Interpreter
    Affects Versions: JRuby 1.5.1
         Environment: Linux Ubuntu 10.04 LTS
JRuby 1.5.1 --1.8
but same error with --1.9
rvm is used
            Reporter: Kai D
            Priority: Critical


The code defined? super causes a NullPointerException in mixins. I use this 
pattern often for method chains in mixins. In MRV and YARV this code works 
properly.

{noformat}
class A
  def x
    puts "A"
  end
end
module B
  def x
    puts "B"
    super() if defined? super()
  end
end
class C < A
  include B
  def x
    puts "C"
    super()
  end
end

C.new.x
__END__
Expected output:
C
B
A

Real output
C
B

With --1.8

bug.rb:-1:in `ensure_1$RUBY$__ensure__': java.lang.NullPointerException
        from bug.rb:9:in `method__3$RUBY$x'
        from bugInvokermethod__3$RUBY$xFixed0#x:65535:in `call'
        from SuperCallSite.java:310:in `cacheAndCall'
        from SuperCallSite.java:110:in `callBlock'
        from SuperCallSite.java:115:in `call'
        from bug.rb:16:in `method__5$RUBY$x'
        from bugInvokermethod__5$RUBY$xFixed0#x:65535:in `call'
        from bugInvokermethod__5$RUBY$xFixed0#x:65535:in `call'
        from CachingCallSite.java:289:in `cacheAndCall'
        from CachingCallSite.java:108:in `call'
        from bug.rb:20:in `__file__'
        from bug.rb:-1:in `load'
        from Ruby.java:685:in `runScript'
        from Ruby.java:568:in `runNormally'
        from Ruby.java:414:in `runFromMain'
        from Main.java:286:in `run'
        from Main.java:128:in `run'
        from Main.java:97:in `main'
  
With --1.9
  
SuperNode.java:119:in `definition': java.lang.NullPointerException
        from DefinedNode.java:86:in `interpret'
        from IfNode.java:111:in `interpret'
        from NewlineNode.java:104:in `interpret'
        from BlockNode.java:71:in `interpret'
        from InterpretedMethod.java:113:in `call'
        from SuperCallSite.java:280:in `cacheAndCall'
        from SuperCallSite.java:64:in `callBlock'
        from SuperCallSite.java:69:in `call'
        from SuperNode.java:111:in `interpret'
        from NewlineNode.java:104:in `interpret'
        from BlockNode.java:71:in `interpret'
        from InterpretedMethod.java:139:in `call'
        from CachingCallSite.java:289:in `cacheAndCall'
        from CachingCallSite.java:108:in `call'
        from CallNoArgNode.java:61:in `interpret'
        from NewlineNode.java:104:in `interpret'
        from BlockNode.java:71:in `interpret'
        from RootNode.java:129:in `interpret'
        from Ruby.java:711:in `runInterpreter'
        from Ruby.java:572:in `runNormally'
        from Ruby.java:414:in `runFromMain'
        from Main.java:286:in `run'
        from Main.java:128:in `run'
        from Main.java:97:in `main'

{noformat}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to