From 72a7a1414b3a1f0e122107ef59a4692f9dfdf67a Mon Sep 17 00:00:00 2001 From: megacz Date: Wed, 6 Mar 2002 22:37:26 +0000 Subject: [PATCH] 2002-03-06 Adam Megacz * java/io/FileDescriptor.java: Initialize in/out/err in init(). * java/io/natFileDescriptorWin32.cc (init()): Added function. * java/io/natFileDescriptorPosix.cc (init()): Added function. * java/io/natFileDescriptorEcos.cc (init()): Added function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50378 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 7 +++++++ libjava/java/io/FileDescriptor.java | 14 ++++++++++---- libjava/java/io/natFileDescriptorEcos.cc | 8 ++++++++ libjava/java/io/natFileDescriptorPosix.cc | 8 ++++++++ libjava/java/io/natFileDescriptorWin32.cc | 11 +++++++++++ 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 1712779..90af4e6 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2002-03-06 Adam Megacz + + * java/io/FileDescriptor.java: Initialize in/out/err in init(). + * java/io/natFileDescriptorWin32.cc (init()): Added function. + * java/io/natFileDescriptorPosix.cc (init()): Added function. + * java/io/natFileDescriptorEcos.cc (init()): Added function. + 2002-03-06 Eric Blake * scripts/unicode-decomp.pl: Move from chartables.pl, and remove diff --git a/libjava/java/io/FileDescriptor.java b/libjava/java/io/FileDescriptor.java index a8bf751..427a26a 100644 --- a/libjava/java/io/FileDescriptor.java +++ b/libjava/java/io/FileDescriptor.java @@ -24,14 +24,20 @@ package java.io; // if need be. public final class FileDescriptor { - public static final FileDescriptor in = new FileDescriptor (0); - public static final FileDescriptor out = new FileDescriptor (1); - public static final FileDescriptor err = new FileDescriptor (2); + + public static final FileDescriptor in = null; + public static final FileDescriptor out = null; + public static final FileDescriptor err = null; + + private static native void init(); + static + { + init(); + } public native void sync () throws SyncFailedException; public native boolean valid (); - // These are mode values for open(). static final int READ = 1; static final int WRITE = 2; diff --git a/libjava/java/io/natFileDescriptorEcos.cc b/libjava/java/io/natFileDescriptorEcos.cc index a66bf73..81e10e2 100644 --- a/libjava/java/io/natFileDescriptorEcos.cc +++ b/libjava/java/io/natFileDescriptorEcos.cc @@ -41,6 +41,14 @@ diag_write (char *data, int len) #define NO_FSYNC_MESSAGE "sync unsupported" +void +java::io::FileDescriptor::init(void) +{ + in = new java::io::FileDescriptor((jint)(GetStdHandle (0))); + out = new java::io::FileDescriptor((jint)(GetStdHandle (1))); + err = new java::io::FileDescriptor((jint)(GetStdHandle (2))); +} + jboolean java::io::FileDescriptor::valid (void) { diff --git a/libjava/java/io/natFileDescriptorPosix.cc b/libjava/java/io/natFileDescriptorPosix.cc index 7c55f56..83a1261 100644 --- a/libjava/java/io/natFileDescriptorPosix.cc +++ b/libjava/java/io/natFileDescriptorPosix.cc @@ -45,6 +45,14 @@ details. */ #define NO_FSYNC_MESSAGE "sync unsupported" +void +java::io::FileDescriptor::init(void) +{ + in = new java::io::FileDescriptor((jint)(GetStdHandle (0))); + out = new java::io::FileDescriptor((jint)(GetStdHandle (1))); + err = new java::io::FileDescriptor((jint)(GetStdHandle (2))); +} + jboolean java::io::FileDescriptor::valid (void) { diff --git a/libjava/java/io/natFileDescriptorWin32.cc b/libjava/java/io/natFileDescriptorWin32.cc index 7c2bbb1..4a9d690 100644 --- a/libjava/java/io/natFileDescriptorWin32.cc +++ b/libjava/java/io/natFileDescriptorWin32.cc @@ -32,6 +32,17 @@ details. */ #include #include +// FIXME: casting a FILE (pointer) to a jint will not work on Win64 -- +// we should be using gnu.gcj.RawData's. + +void +java::io::FileDescriptor::init(void) +{ + in = new java::io::FileDescriptor((jint)(GetStdHandle (STD_INPUT_HANDLE))); + out = new java::io::FileDescriptor((jint)(GetStdHandle (STD_OUTPUT_HANDLE))); + err = new java::io::FileDescriptor((jint)(GetStdHandle (STD_ERROR_HANDLE))); +} + static char * winerr (void) { -- 2.7.4