Java::JavaLang::NullPointerException when calling super in method in duped module included in subclass #1070

Closed
headius opened this Issue Oct 1, 2013 · 2 comments

Projects

None yet

3 participants

@headius
Member
headius commented Oct 1, 2013

Copied from http://jira.codehaus.org/browse/JRUBY-7172

Running the following code causes a Java::JavaLang::NullPointerException in all JRuby installations I tried. It happens in irb, but not if you put the code in a file and run it from the command line.

class A
  def b
  end
end

module M
  def b
    super
  end
end

class B < A
  include M.dup
end
B.new.b
Java::JavaLang::NullPointerException:
        from org.jruby.runtime.callsite.SuperCallSite.pollAndGetClass(SuperCallSite.java:455)
        from org.jruby.runtime.callsite.SuperCallSite.callBlock(SuperCallSite.java:140)
        from org.jruby.runtime.callsite.SuperCallSite.call(SuperCallSite.java:151)
        from org.jruby.runtime.callsite.SuperCallSite.callVarargs(SuperCallSite.java:107)
        from org.jruby.ast.ZSuperNode.interpret(ZSuperNode.java:103)
        from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
        from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
        from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:139)
        from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:170)
        from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306)
        from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136)
        from org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60)
        from org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
        from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
        from org.jruby.ast.RootNode.interpret(RootNode.java:129)
        from org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:95)
... 121 levels...
        from org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
        from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
        from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:186)
        from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
        from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
        from usr.local.jruby.bin.jirb.__file__(/usr/local/jruby/bin/jirb:13)
        from usr.local.jruby.bin.jirb.load(/usr/local/jruby/bin/jirb)
        from org.jruby.Ruby.runScript(Ruby.java:807)
        from org.jruby.Ruby.runScript(Ruby.java:800)
        from org.jruby.Ruby.runNormally(Ruby.java:669)
        from org.jruby.Ruby.runFromMain(Ruby.java:518)
        from org.jruby.Main.doRunFromMain(Main.java:390)
        from org.jruby.Main.internalRun(Main.java:279)
        from org.jruby.Main.run(Main.java:221)
        from org.jruby.Main.main(Main.java:201)
@headius
Member
headius commented Oct 1, 2013

Mike Luu got the same issue with different code, commenting in the original issue:

class Foo; end

module A
def bar; 1; end
end

module AA
def bar; super+1; end
end

q = Foo.new
q.extend A.clone
q.extend AA.clone
puts q.bar
@MSNexploder
Contributor

Works correctly in both - jruby 1.7.13 and master.

@kares kares closed this Apr 8, 2016
@kares kares added this to the JRuby 1.7.13 milestone Apr 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment