Index: test/test_file.rb
===================================================================
--- test/test_file.rb	(revision 4779)
+++ test/test_file.rb	(working copy)
@@ -277,6 +277,12 @@
     File.delete(filename)
   end
 
+  # http://jira.codehaus.org/browse/JRUBY-1023
+  def test_file_reuse_fileno
+    fh = File.new(STDIN.fileno, 'r')
+    assert_equal(STDIN.fileno, fh.fileno)
+  end
+
   # http://jira.codehaus.org/browse/JRUBY-1231
   def test_file_directory_empty_name
     assert !File.directory?("")
Index: src/org/jruby/RubyFile.java
===================================================================
--- src/org/jruby/RubyFile.java	(revision 4779)
+++ src/org/jruby/RubyFile.java	(working copy)
@@ -48,6 +48,7 @@
 import org.jruby.runtime.Arity;
 import org.jruby.runtime.Block;
 import org.jruby.runtime.CallbackFactory;
+import org.jruby.runtime.MethodIndex;
 import org.jruby.runtime.ObjectAllocator;
 import org.jruby.runtime.ThreadContext;
 import org.jruby.runtime.Visibility;
@@ -357,6 +358,13 @@
         if (args.length == 0) {
             throw getRuntime().newArgumentError(0, 1);
         }
+        else if (args.length < 3) {
+            IRubyObject fd = args[0].convertToTypeWithCheck(getRuntime().getFixnum(), MethodIndex.TO_INT, "to_int");
+            if (!fd.isNil()) {
+                args[0] = fd;
+                return super.initialize(args, block);
+            }
+        }
 
         getRuntime().checkSafeString(args[0]);
         path = args[0].toString();

