Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.5.1
-
Fix Version/s: JRuby 1.6RC1
-
Component/s: Interpreter
-
Labels:None
-
Environment:Linux Ubuntu 10.04 LTS
JRuby 1.5.1 --1.8
but same error with --1.9
rvm is used
-
Number of attachments :
Description
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.
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'
Issue Links
- is related to
-
JRUBY-4776
calling defined?(super) in a module method causes a NullPointerException
-
Data points: