Skip to content

jrubyc won't compile a file with method in outer scope (NoMethodError: undefined method `new_method' for nil:NilClass) #3599

@ruskotron

Description

@ruskotron

Looking at the example at https://github.com/jruby/jruby/wiki/JRubyCompiler

This should be possible i.e.

def my_method
  puts 'splat'
end

my_method

results in a error like this from jrubyc:

 $ java -jar tools/jruby-complete-9.0.4.0.jar -S jrubyc --verbose --javac outer.rb
NoMethodError: undefined method `new_method' for nil:NilClass
                           new_method at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler/java_class.rb:115
             block in ClassNodeWalker at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler/java_class.rb:239
 .. and so on ...

This works fine when executed as a script e.g.

 $ java -jar tools/jruby-complete-9.0.4.0.jar  outer.rb
splat

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions