DATA.flock causes ClassCastException
------------------------------------

                 Key: JRUBY-2542
                 URL: http://jira.codehaus.org/browse/JRUBY-2542
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.1.1
         Environment: Windows XP, Java 1.6, JRuby 1.1.1
            Reporter: Daniel Berger


The following script works fine in MRI, but causes an error in JRuby:
{noformat}
class Foo
   def self.mainloop
      while true
         puts "Looping..."
         sleep 3
      end
   end
end

DATA.flock(File::LOCK_EX)

if $0 == __FILE__
   Foo.mainloop
end

__END__
{noformat}
With JRuby I get:

C:\Documents and Settings\djberge\My 
Documents\Programming\Ruby>c:\jruby\bin\jruby lock_test.rb
Exception in thread "main" java.lang.ClassCastException: 
java.nio.channels.Channels$ReadableByteChannelImpl cannot be cast to 
java.nio.channels.FileChannel
        at org.jruby.RubyFile.flock(RubyFile.java:286)
        at org.jruby.RubyFileInvoker$flock_method_1_0.call(Unknown Source)
        at 
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:146)
        at 
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:302)
        at 
ruby.C_3a_.Documents_20_and_20_Settings.djberge.My_20_Documents.Programming.Ruby.lock_test.__file__(lock_test.rb:10)
        at 
ruby.C_3a_.Documents_20_and_20_Settings.djberge.My_20_Documents.Programming.Ruby.lock_test.load(lock_test.rb)
        at org.jruby.Ruby.runScript(Ruby.java:511)
        at org.jruby.Ruby.runNormally(Ruby.java:431)
        at org.jruby.Ruby.runFromMain(Ruby.java:311)
        at org.jruby.Main.run(Main.java:144)
        at org.jruby.Main.run(Main.java:89)
        at org.jruby.Main.main(Main.java:80)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to