Index: test/test_io.rb
===================================================================
--- test/test_io.rb	(revision 4889)
+++ test/test_io.rb	(working copy)
@@ -33,6 +33,15 @@
     assert(b == "\nB\n", "gets of non-paragraph \"\\n\\n\" failed")
   end
 
+  def test_fd_for_alias
+    f = File.new(@file, "w")
+    f.puts("heh")
+    g = IO.for_fd(f.fileno)
+    assert_kind_of(IO, g)
+    assert_equal(f.fileno, g.fileno)
+    assert(!g.closed?)
+  end
+
   def test_two_ios_with_same_filenos
     # Two ios with same fileno, but different objects.
     f = File.new(@file, "w")
Index: src/org/jruby/RubyIO.java
===================================================================
--- src/org/jruby/RubyIO.java	(revision 4889)
+++ src/org/jruby/RubyIO.java	(working copy)
@@ -286,6 +286,7 @@
         // we could invoke jruby differently to allow stdin to return true
         // on this.  This would allow things like cgi.rb to work properly.
         
+        ioMetaClass.defineAlias("for_fd","new");
         ioMetaClass.defineMethod("open", callbackFactory.getOptSingletonMethod("open"));
         ioMetaClass.defineMethod("foreach", callbackFactory.getOptSingletonMethod("foreach"));
         ioMetaClass.defineMethod("read", callbackFactory.getOptSingletonMethod("read"));

