The Socket/BasicSocket dichotomy is certainly an interesting issue. It doesn't seem to be a simple issue of singleton methods, since File's singleton methods work fine in extending classes:

class F < File
end

F.dirname  => wrong number of arguments (i.e. it's finding it ok)

So there's something odd about Socket/BasicSocket specifically.

Also, I noticed now that do_not_reverse_lookup is implemented as a static var in RubyBasicSocket. That needs to be fixed.

On 6/13/06, Ola Bini <[EMAIL PROTECTED]> wrote:
Well, so I've found the first thing that's a problem with script/server,
at least on my win32-box. The server script first tries to determine
which server to use. It does this by all different manners of fun
tricks. This one:
   if RUBY_PLATFORM !~ /mswin/ && !silence_stderr { `lighttpd -version`
}.blank? && defined?(FCGI)

is especially fun; just look at that silence_stderr ... so what does it do?
well, silence_stderr is part of active support, it more or less calls on
silence_stream, that looks like this:

  def silence_stream(stream)
    old_stream = stream.dup
    stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
    stream.sync = true
    yield
  ensure
    stream.reopen(old_stream)
  end

and, since I'm on win, this will try to open /dev/null. Now, commenting
out this, to get to the next step, we find this fine error:

D:/project/jruby/lib/ruby/gems/1.8/gems/rails- 1.1.2/lib/webrick_server.rb:53:in
`method_missing': undefined method `do_not_reverse_lookup='
for Socket:Class (NoMethodError)
        from
D:/project/jruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:53:in
`dispatch'

And well, this is where it seems we have a real problem. I'm not
entirely sure about this, it's only a hypothesis. But that method is
defined, in BasicSocketMetaClass as a singleton method. and the Socket
class is defined in socket.rb to inherit BasicSocket. but look at this
jirb session:

irb(main):002:0> require 'socket'
=> true
irb(main):003:0> Socket.do_not_reverse_lookup
NoMethodError: undefined method `do_not_reverse_lookup' for Socket:Class
        from (irb):1:in `method_missing'
        from (irb):1
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:150:in
`eval_input'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:70:in
`signal_status'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:189:in
`eval_input'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:70:in
`each_top_level_statement'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:190:in `loop'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:190:in `catch'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:190:in
`eval_input'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:70:in `start'
        from D:\project\jruby\bin\jirb:13:in `catch'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:71:in `start'
        from D:\project\jruby\bin\jirb:13
irb(main):004:0> BasicSocket.do_not_reverse_lookup
=> false
irb(main):005:0> BasicSocket.do_not_reverse_lookup=true
=> true
irb(main):006:0> Socket.do_not_reverse_lookup=true
NoMethodError: undefined method `do_not_reverse_lookup=' for Socket:Class
        from (irb):1:in `method_missing'
        from (irb):1
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:150:in
`eval_input'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:70:in
`signal_status'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:189:in
`eval_input'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:70:in
`each_top_level_statement'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:190:in `loop'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:190:in `catch'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:190:in
`eval_input'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:70:in `start'
        from D:\project\jruby\bin\jirb:13:in `catch'
        from D:/project/jruby/lib/ruby/site_ruby/1.8/irb.rb:71:in `start'
        from D:\project\jruby\bin\jirb:13
irb(main):007:0>


It seems that the singleton methods from BasicSocket aren't inherited by
the Socket class. I guess this is because of some major strange thing
between defining a Java MetaClass and subclassing it from Ruby.

Anyway, anyone know where to continue?

Regards
Ola Bini


ps ... oh yeah, for anyone who wants to go drooling... by changing from
Socket to BasicSocket in the line above I got this little output...

D:\Project\testjrails\test1>jruby script\server
D:/project/jruby/lib/ruby/gems/1.8/gems/activerecord- 1.14.2/lib/active_record/connection_adapters/oracle_adapter.rb:118
warning: (...) interpreted as grouped _expression_
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-06-13 22:22:35] INFO  WEBrick 1.3.1
[2006-06-13 22:22:35] INFO  ruby 1.8.4 (0) [java]
[2006-06-13 22:22:35] INFO  WEBrick::HTTPServer#start: pid=7214088 port=3000
127.0.0.1 - - [13/Jun/2006:22:26:35 CEST] "GET / HTTP/1.1" 200 7
- -> /
127.0.0.1 - - [13/Jun/2006:22:26:35 CEST] "GET /favicon.ico HTTP/1.1" 200 0
- -> /favicon.ico


it doesn't really serve anything, though, for some reason, but Charlie
have said he'll continue from here... =)

Nighti
/O



_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel



--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com
_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel

Reply via email to