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)
@@ -380,6 +380,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();

