logo       

Java integration and module mixing in: msg#00036

lang.jruby.user

Subject: Java integration and module mixing in

Hello,

This script fails for me with the following exception:

require 'java'

module Java
  include_class 'java.util.ArrayList'

  module Foo
    def hello; puts "hello"; end
  end

  class ArrayList
    include Foo  # fails here; line 11
  end
end

l = Java::ArrayList.new
l.hello
l.add("hi")
puts l.toString()

$ jruby const_test.rb
P:\ruby\jruby\jruby- 0.8.2\src\builtin\javasupport.rb:148:in `const_missing': uninitialized constant Foo at ArrayList (NameError)
        from P:\ruby\jruby\jruby-0.8.2\src\builtin\javasupport.rb:148:in `const_missing'
        from const_test.rb:11
        from :0
        from :0
[exited with 1]

If I change the failing line to "include Java::Foo" it works fine.
A simpler script that mixes in a module without using the java integration works fine.  Is this a bug?  If so, I'll try to contribute a patch, but I might not be able to get to it right away...

Cheers,
/Nick
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise