summaryrefslogtreecommitdiff
path: root/libjava/java/io
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/java/io
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libjava/java/io')
-rw-r--r--libjava/java/io/BufferedInputStream.h43
-rw-r--r--libjava/java/io/BufferedInputStream.java390
-rw-r--r--libjava/java/io/BufferedOutputStream.h31
-rw-r--r--libjava/java/io/BufferedReader.h47
-rw-r--r--libjava/java/io/BufferedWriter.h36
-rw-r--r--libjava/java/io/ByteArrayInputStream.h35
-rw-r--r--libjava/java/io/ByteArrayOutputStream.h41
-rw-r--r--libjava/java/io/CharArrayReader.h36
-rw-r--r--libjava/java/io/CharArrayWriter.h50
-rw-r--r--libjava/java/io/CharConversionException.h23
-rw-r--r--libjava/java/io/Closeable.h19
-rw-r--r--libjava/java/io/DataInput.h35
-rw-r--r--libjava/java/io/DataInputStream.h56
-rw-r--r--libjava/java/io/DataOutput.h34
-rw-r--r--libjava/java/io/DataOutputStream.h49
-rw-r--r--libjava/java/io/DeleteFileHelper$1.h21
-rw-r--r--libjava/java/io/DeleteFileHelper.h28
-rw-r--r--libjava/java/io/EOFException.h23
-rw-r--r--libjava/java/io/Externalizable.h20
-rw-r--r--libjava/java/io/File.h164
-rw-r--r--libjava/java/io/File.java1579
-rw-r--r--libjava/java/io/FileDescriptor.h43
-rw-r--r--libjava/java/io/FileDescriptor.java139
-rw-r--r--libjava/java/io/FileFilter.h19
-rw-r--r--libjava/java/io/FileInputStream.h67
-rw-r--r--libjava/java/io/FileInputStream.java309
-rw-r--r--libjava/java/io/FileNotFoundException.h23
-rw-r--r--libjava/java/io/FileOutputStream.h66
-rw-r--r--libjava/java/io/FileOutputStream.java296
-rw-r--r--libjava/java/io/FilePermission.h43
-rw-r--r--libjava/java/io/FileReader.h21
-rw-r--r--libjava/java/io/FileWriter.h23
-rw-r--r--libjava/java/io/FilenameFilter.h19
-rw-r--r--libjava/java/io/FilterInputStream.h34
-rw-r--r--libjava/java/io/FilterOutputStream.h29
-rw-r--r--libjava/java/io/FilterReader.h33
-rw-r--r--libjava/java/io/FilterWriter.h30
-rw-r--r--libjava/java/io/Flushable.h19
-rw-r--r--libjava/java/io/IOException.h23
-rw-r--r--libjava/java/io/InputStream.h30
-rw-r--r--libjava/java/io/InputStreamReader.h65
-rw-r--r--libjava/java/io/InputStreamReader.java332
-rw-r--r--libjava/java/io/InterruptedIOException.h26
-rw-r--r--libjava/java/io/InvalidClassException.h25
-rw-r--r--libjava/java/io/InvalidObjectException.h22
-rw-r--r--libjava/java/io/LineNumberInputStream.h34
-rw-r--r--libjava/java/io/LineNumberReader.h41
-rw-r--r--libjava/java/io/NotActiveException.h23
-rw-r--r--libjava/java/io/NotSerializableException.h23
-rw-r--r--libjava/java/io/ObjectInput.h42
-rw-r--r--libjava/java/io/ObjectInputStream$1.h26
-rw-r--r--libjava/java/io/ObjectInputStream$2.h42
-rw-r--r--libjava/java/io/ObjectInputStream$GetField.h30
-rw-r--r--libjava/java/io/ObjectInputStream$ValidatorAndPriority.h25
-rw-r--r--libjava/java/io/ObjectInputStream.h106
-rw-r--r--libjava/java/io/ObjectInputValidation.h19
-rw-r--r--libjava/java/io/ObjectOutput.h37
-rw-r--r--libjava/java/io/ObjectOutputStream$1.h41
-rw-r--r--libjava/java/io/ObjectOutputStream$PutField.h29
-rw-r--r--libjava/java/io/ObjectOutputStream.h126
-rw-r--r--libjava/java/io/ObjectStreamClass$1.h24
-rw-r--r--libjava/java/io/ObjectStreamClass$2.h26
-rw-r--r--libjava/java/io/ObjectStreamClass$InterfaceComparator.h23
-rw-r--r--libjava/java/io/ObjectStreamClass$MemberComparator.h23
-rw-r--r--libjava/java/io/ObjectStreamClass.h117
-rw-r--r--libjava/java/io/ObjectStreamConstants.h47
-rw-r--r--libjava/java/io/ObjectStreamException.h23
-rw-r--r--libjava/java/io/ObjectStreamField$1.h26
-rw-r--r--libjava/java/io/ObjectStreamField.h67
-rw-r--r--libjava/java/io/OptionalDataException.h24
-rw-r--r--libjava/java/io/OutputStream.h26
-rw-r--r--libjava/java/io/OutputStreamWriter.h65
-rw-r--r--libjava/java/io/OutputStreamWriter.java347
-rw-r--r--libjava/java/io/PipedInputStream.h45
-rw-r--r--libjava/java/io/PipedOutputStream.h31
-rw-r--r--libjava/java/io/PipedReader.h39
-rw-r--r--libjava/java/io/PipedWriter.h32
-rw-r--r--libjava/java/io/PrintStream.h93
-rw-r--r--libjava/java/io/PrintStream.java684
-rw-r--r--libjava/java/io/PrintWriter.h80
-rw-r--r--libjava/java/io/PushbackInputStream.h38
-rw-r--r--libjava/java/io/PushbackReader.h38
-rw-r--r--libjava/java/io/RandomAccessFile.h93
-rw-r--r--libjava/java/io/RandomAccessFile.java1036
-rw-r--r--libjava/java/io/Reader.h46
-rw-r--r--libjava/java/io/SequenceInputStream.h32
-rw-r--r--libjava/java/io/Serializable.h18
-rw-r--r--libjava/java/io/SerializablePermission.h27
-rw-r--r--libjava/java/io/StreamCorruptedException.h23
-rw-r--r--libjava/java/io/StreamTokenizer.h72
-rw-r--r--libjava/java/io/StringBufferInputStream.h31
-rw-r--r--libjava/java/io/StringReader.h35
-rw-r--r--libjava/java/io/StringWriter.h43
-rw-r--r--libjava/java/io/SyncFailedException.h22
-rw-r--r--libjava/java/io/UTFDataFormatException.h23
-rw-r--r--libjava/java/io/UnsupportedEncodingException.h23
-rw-r--r--libjava/java/io/VMObjectInputStream.h21
-rw-r--r--libjava/java/io/VMObjectInputStream.java56
-rw-r--r--libjava/java/io/VMObjectStreamClass.h30
-rw-r--r--libjava/java/io/VMObjectStreamClass.java140
-rw-r--r--libjava/java/io/WriteAbortedException.h25
-rw-r--r--libjava/java/io/Writer.h39
-rw-r--r--libjava/java/io/natFilePosix.cc509
-rw-r--r--libjava/java/io/natFileWin32.cc374
-rw-r--r--libjava/java/io/natVMObjectInputStream.cc71
-rw-r--r--libjava/java/io/natVMObjectStreamClass.cc87
106 files changed, 9934 insertions, 0 deletions
diff --git a/libjava/java/io/BufferedInputStream.h b/libjava/java/io/BufferedInputStream.h
new file mode 100644
index 000000000..d2851da73
--- /dev/null
+++ b/libjava/java/io/BufferedInputStream.h
@@ -0,0 +1,43 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_BufferedInputStream__
+#define __java_io_BufferedInputStream__
+
+#pragma interface
+
+#include <java/io/FilterInputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::BufferedInputStream : public ::java::io::FilterInputStream
+{
+
+public:
+ BufferedInputStream(::java::io::InputStream *);
+ BufferedInputStream(::java::io::InputStream *, jint);
+ virtual jint available();
+ virtual void close();
+ virtual void mark(jint);
+ virtual jboolean markSupported();
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual void reset();
+ virtual jlong skip(jlong);
+public: // actually package-private
+ virtual jboolean refill();
+private:
+ static const jint DEFAULT_BUFFER_SIZE = 2048;
+public: // actually protected
+ JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::io::FilterInputStream)))) buf;
+ jint count;
+ jint pos;
+ jint markpos;
+ jint marklimit;
+private:
+ jint bufferSize;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_BufferedInputStream__
diff --git a/libjava/java/io/BufferedInputStream.java b/libjava/java/io/BufferedInputStream.java
new file mode 100644
index 000000000..36e58f636
--- /dev/null
+++ b/libjava/java/io/BufferedInputStream.java
@@ -0,0 +1,390 @@
+/* BufferedInputStream.java -- An input stream that implements buffering
+ Copyright (C) 1998, 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * This subclass of <code>FilterInputStream</code> buffers input from an
+ * underlying implementation to provide a possibly more efficient read
+ * mechanism. It maintains the buffer and buffer state in instance
+ * variables that are available to subclasses. The default buffer size
+ * of 2048 bytes can be overridden by the creator of the stream.
+ * <p>
+ * This class also implements mark/reset functionality. It is capable
+ * of remembering any number of input bytes, to the limits of
+ * system memory or the size of <code>Integer.MAX_VALUE</code>
+ * <p>
+ * Please note that this class does not properly handle character
+ * encodings. Consider using the <code>BufferedReader</code> class which
+ * does.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @author Jeroen Frijters (jeroen@frijters.net)
+ */
+public class BufferedInputStream extends FilterInputStream
+{
+
+ /**
+ * This is the default buffer size
+ */
+ private static final int DEFAULT_BUFFER_SIZE = 2048;
+
+ /**
+ * The buffer used for storing data from the underlying stream.
+ */
+ protected byte[] buf;
+
+ /**
+ * The number of valid bytes currently in the buffer. It is also the index
+ * of the buffer position one byte past the end of the valid data.
+ */
+ protected int count;
+
+ /**
+ * The index of the next character that will by read from the buffer.
+ * When <code>pos == count</code>, the buffer is empty.
+ */
+ protected int pos;
+
+ /**
+ * The value of <code>pos</code> when the <code>mark()</code> method was
+ * called.
+ * This is set to -1 if there is no mark set.
+ */
+ protected int markpos = -1;
+
+ /**
+ * This is the maximum number of bytes than can be read after a
+ * call to <code>mark()</code> before the mark can be discarded.
+ * After this may bytes are read, the <code>reset()</code> method
+ * may not be called successfully.
+ */
+ protected int marklimit;
+
+ /**
+ * This is the initial buffer size. When the buffer is grown because
+ * of marking requirements, it will be grown by bufferSize increments.
+ * The underlying stream will be read in chunks of bufferSize.
+ */
+ private final int bufferSize;
+
+ /**
+ * This method initializes a new <code>BufferedInputStream</code> that will
+ * read from the specified subordinate stream with a default buffer size
+ * of 2048 bytes
+ *
+ * @param in The subordinate stream to read from
+ */
+ public BufferedInputStream(InputStream in)
+ {
+ this(in, DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * This method initializes a new <code>BufferedInputStream</code> that will
+ * read from the specified subordinate stream with a buffer size that
+ * is specified by the caller.
+ *
+ * @param in The subordinate stream to read from
+ * @param size The buffer size to use
+ *
+ * @exception IllegalArgumentException when size is smaller then 1
+ */
+ public BufferedInputStream(InputStream in, int size)
+ {
+ super(in);
+ if (size <= 0)
+ throw new IllegalArgumentException();
+ buf = new byte[size];
+ // initialize pos & count to bufferSize, to prevent refill from
+ // allocating a new buffer (if the caller starts out by calling mark()).
+ pos = count = bufferSize = size;
+ }
+
+ /**
+ * This method returns the number of bytes that can be read from this
+ * stream before a read can block. A return of 0 indicates that blocking
+ * might (or might not) occur on the very next read attempt.
+ * <p>
+ * The number of available bytes will be the number of read ahead bytes
+ * stored in the internal buffer plus the number of available bytes in
+ * the underlying stream.
+ *
+ * @return The number of bytes that can be read before blocking could occur
+ *
+ * @exception IOException If an error occurs
+ */
+ public synchronized int available() throws IOException
+ {
+ return count - pos + in.available();
+ }
+
+ /**
+ * This method closes the underlying input stream and frees any
+ * resources associated with it. Sets <code>buf</code> to <code>null</code>.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public void close() throws IOException
+ {
+ // Free up the array memory.
+ buf = null;
+ pos = count = 0;
+ markpos = -1;
+ in.close();
+ }
+
+ /**
+ * This method marks a position in the input to which the stream can be
+ * "reset" by calling the <code>reset()</code> method. The parameter
+ * <code>readlimit</code> is the number of bytes that can be read from the
+ * stream after setting the mark before the mark becomes invalid. For
+ * example, if <code>mark()</code> is called with a read limit of 10, then
+ * when 11 bytes of data are read from the stream before the
+ * <code>reset()</code> method is called, then the mark is invalid and the
+ * stream object instance is not required to remember the mark.
+ * <p>
+ * Note that the number of bytes that can be remembered by this method
+ * can be greater than the size of the internal read buffer. It is also
+ * not dependent on the subordinate stream supporting mark/reset
+ * functionality.
+ *
+ * @param readlimit The number of bytes that can be read before the mark
+ * becomes invalid
+ */
+ public synchronized void mark(int readlimit)
+ {
+ marklimit = readlimit;
+ markpos = pos;
+ }
+
+ /**
+ * This method returns <code>true</code> to indicate that this class
+ * supports mark/reset functionality.
+ *
+ * @return <code>true</code> to indicate that mark/reset functionality is
+ * supported
+ *
+ */
+ public boolean markSupported()
+ {
+ return true;
+ }
+
+ /**
+ * This method reads an unsigned byte from the input stream and returns it
+ * as an int in the range of 0-255. This method also will return -1 if
+ * the end of the stream has been reached.
+ * <p>
+ * This method will block until the byte can be read.
+ *
+ * @return The byte read or -1 if end of stream
+ *
+ * @exception IOException If an error occurs
+ */
+ public synchronized int read() throws IOException
+ {
+ if (pos >= count && !refill())
+ return -1; // EOF
+
+ return buf[pos++] & 0xFF;
+ }
+
+ /**
+ * This method reads bytes from a stream and stores them into a caller
+ * supplied buffer. It starts storing the data at index <code>off</code>
+ * into the buffer and attempts to read <code>len</code> bytes. This method
+ * can return before reading the number of bytes requested, but it will try
+ * to read the requested number of bytes by repeatedly calling the underlying
+ * stream as long as available() for this stream continues to return a
+ * non-zero value (or until the requested number of bytes have been read).
+ * The actual number of bytes read is returned as an int. A -1 is returned
+ * to indicate the end of the stream.
+ * <p>
+ * This method will block until some data can be read.
+ *
+ * @param b The array into which the bytes read should be stored
+ * @param off The offset into the array to start storing bytes
+ * @param len The requested number of bytes to read
+ *
+ * @return The actual number of bytes read, or -1 if end of stream.
+ *
+ * @exception IOException If an error occurs.
+ * @exception IndexOutOfBoundsException when <code>off</code> or
+ * <code>len</code> are negative, or when <code>off + len</code>
+ * is larger then the size of <code>b</code>,
+ */
+ public synchronized int read(byte[] b, int off, int len) throws IOException
+ {
+ if (off < 0 || len < 0 || b.length - off < len)
+ throw new IndexOutOfBoundsException();
+
+ if (len == 0)
+ return 0;
+
+ if (pos >= count && !refill())
+ return -1; // No bytes were read before EOF.
+
+ int totalBytesRead = Math.min(count - pos, len);
+ System.arraycopy(buf, pos, b, off, totalBytesRead);
+ pos += totalBytesRead;
+ off += totalBytesRead;
+ len -= totalBytesRead;
+
+ while (len > 0 && in.available() > 0 && refill())
+ {
+ int remain = Math.min(count - pos, len);
+ System.arraycopy(buf, pos, b, off, remain);
+ pos += remain;
+ off += remain;
+ len -= remain;
+ totalBytesRead += remain;
+ }
+
+ return totalBytesRead;
+ }
+
+ /**
+ * This method resets a stream to the point where the <code>mark()</code>
+ * method was called. Any bytes that were read after the mark point was
+ * set will be re-read during subsequent reads.
+ * <p>
+ * This method will throw an IOException if the number of bytes read from
+ * the stream since the call to <code>mark()</code> exceeds the mark limit
+ * passed when establishing the mark.
+ *
+ * @exception IOException If <code>mark()</code> was never called or more
+ * then <code>marklimit</code> bytes were read since the last
+ * call to <code>mark()</code>
+ */
+ public synchronized void reset() throws IOException
+ {
+ if (markpos == -1)
+ throw new IOException(buf == null ? "Stream closed." : "Invalid mark.");
+
+ pos = markpos;
+ }
+
+ /**
+ * This method skips the specified number of bytes in the stream. It
+ * returns the actual number of bytes skipped, which may be less than the
+ * requested amount.
+ *
+ * @param n The requested number of bytes to skip
+ *
+ * @return The actual number of bytes skipped.
+ *
+ * @exception IOException If an error occurs
+ */
+ public synchronized long skip(long n) throws IOException
+ {
+ if (buf == null)
+ throw new IOException("Stream closed.");
+
+ final long origN = n;
+
+ while (n > 0L)
+ {
+ if (pos >= count)
+ {
+ if (markpos == -1)
+ {
+ // Buffer is empty and no mark is set, skip on the
+ // underlying stream.
+ n -= in.skip(n);
+ break;
+ }
+ else if (!refill())
+ break;
+ }
+
+ int numread = (int) Math.min((long) (count - pos), n);
+ pos += numread;
+ n -= numread;
+ }
+
+ return origN - n;
+ }
+
+ // GCJ LOCAL: package-private for use by InputStreamReader
+ /**
+ * Called to refill the buffer (when count is equal to pos).
+ *
+ * @return <code>true</code> when at least one additional byte was read
+ * into <code>buf</code>, <code>false</code> otherwise (at EOF).
+ */
+ boolean refill() throws IOException
+ {
+ if (buf == null)
+ throw new IOException("Stream closed.");
+
+ if (markpos == -1 || count - markpos >= marklimit)
+ {
+ markpos = -1;
+ pos = count = 0;
+ }
+ else
+ {
+ byte[] newbuf = buf;
+ if (markpos < bufferSize)
+ {
+ newbuf = new byte[count - markpos + bufferSize];
+ }
+ System.arraycopy(buf, markpos, newbuf, 0, count - markpos);
+ buf = newbuf;
+ count -= markpos;
+ pos -= markpos;
+ markpos = 0;
+ }
+
+ int numread = in.read(buf, count, bufferSize);
+
+ if (numread <= 0) // EOF
+ return false;
+
+ count += numread;
+ return true;
+ }
+}
diff --git a/libjava/java/io/BufferedOutputStream.h b/libjava/java/io/BufferedOutputStream.h
new file mode 100644
index 000000000..ce34567c6
--- /dev/null
+++ b/libjava/java/io/BufferedOutputStream.h
@@ -0,0 +1,31 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_BufferedOutputStream__
+#define __java_io_BufferedOutputStream__
+
+#pragma interface
+
+#include <java/io/FilterOutputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::BufferedOutputStream : public ::java::io::FilterOutputStream
+{
+
+public:
+ BufferedOutputStream(::java::io::OutputStream *);
+ BufferedOutputStream(::java::io::OutputStream *, jint);
+ virtual void flush();
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *, jint, jint);
+private:
+ static const jint DEFAULT_BUFFER_SIZE = 512;
+public: // actually protected
+ JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::io::FilterOutputStream)))) buf;
+ jint count;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_BufferedOutputStream__
diff --git a/libjava/java/io/BufferedReader.h b/libjava/java/io/BufferedReader.h
new file mode 100644
index 000000000..110477377
--- /dev/null
+++ b/libjava/java/io/BufferedReader.h
@@ -0,0 +1,47 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_BufferedReader__
+#define __java_io_BufferedReader__
+
+#pragma interface
+
+#include <java/io/Reader.h>
+#include <gcj/array.h>
+
+
+class java::io::BufferedReader : public ::java::io::Reader
+{
+
+public:
+ BufferedReader(::java::io::Reader *);
+ BufferedReader(::java::io::Reader *, jint);
+ virtual void close();
+ virtual jboolean markSupported();
+ virtual void mark(jint);
+ virtual void reset();
+ virtual jboolean ready();
+ virtual jint read(JArray< jchar > *, jint, jint);
+private:
+ jint fill();
+public:
+ virtual jint read();
+private:
+ jint lineEnd(jint);
+public:
+ virtual ::java::lang::String * readLine();
+ virtual jlong skip(jlong);
+private:
+ void checkStatus();
+public: // actually package-private
+ ::java::io::Reader * __attribute__((aligned(__alignof__( ::java::io::Reader)))) in;
+ JArray< jchar > * buffer;
+ jint pos;
+ jint limit;
+ jint markPos;
+ static const jint DEFAULT_BUFFER_SIZE = 8192;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_BufferedReader__
diff --git a/libjava/java/io/BufferedWriter.h b/libjava/java/io/BufferedWriter.h
new file mode 100644
index 000000000..68cfa095e
--- /dev/null
+++ b/libjava/java/io/BufferedWriter.h
@@ -0,0 +1,36 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_BufferedWriter__
+#define __java_io_BufferedWriter__
+
+#pragma interface
+
+#include <java/io/Writer.h>
+#include <gcj/array.h>
+
+
+class java::io::BufferedWriter : public ::java::io::Writer
+{
+
+public:
+ BufferedWriter(::java::io::Writer *);
+ BufferedWriter(::java::io::Writer *, jint);
+ virtual void close();
+ virtual void flush();
+ virtual void newLine();
+ virtual void write(jint);
+ virtual void write(JArray< jchar > *, jint, jint);
+ virtual void write(::java::lang::String *, jint, jint);
+private:
+ void localFlush();
+ static const jint DEFAULT_BUFFER_SIZE = 8192;
+ ::java::io::Writer * __attribute__((aligned(__alignof__( ::java::io::Writer)))) out;
+public: // actually package-private
+ JArray< jchar > * buffer;
+ jint count;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_BufferedWriter__
diff --git a/libjava/java/io/ByteArrayInputStream.h b/libjava/java/io/ByteArrayInputStream.h
new file mode 100644
index 000000000..85411b3e0
--- /dev/null
+++ b/libjava/java/io/ByteArrayInputStream.h
@@ -0,0 +1,35 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ByteArrayInputStream__
+#define __java_io_ByteArrayInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::ByteArrayInputStream : public ::java::io::InputStream
+{
+
+public:
+ ByteArrayInputStream(JArray< jbyte > *);
+ ByteArrayInputStream(JArray< jbyte > *, jint, jint);
+ virtual jint available();
+ virtual void mark(jint);
+ virtual jboolean markSupported();
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual void reset();
+ virtual jlong skip(jlong);
+public: // actually protected
+ JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) buf;
+ jint pos;
+ jint mark__;
+ jint count;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ByteArrayInputStream__
diff --git a/libjava/java/io/ByteArrayOutputStream.h b/libjava/java/io/ByteArrayOutputStream.h
new file mode 100644
index 000000000..907c3d4ec
--- /dev/null
+++ b/libjava/java/io/ByteArrayOutputStream.h
@@ -0,0 +1,41 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ByteArrayOutputStream__
+#define __java_io_ByteArrayOutputStream__
+
+#pragma interface
+
+#include <java/io/OutputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::ByteArrayOutputStream : public ::java::io::OutputStream
+{
+
+public:
+ ByteArrayOutputStream();
+ ByteArrayOutputStream(jint);
+ virtual void reset();
+ virtual jint size();
+ virtual JArray< jbyte > * toByteArray();
+ virtual ::java::lang::String * toString();
+ virtual ::java::lang::String * toString(::java::lang::String *);
+ virtual ::java::lang::String * toString(jint);
+private:
+ void resize(jint);
+public:
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual void writeTo(::java::io::OutputStream *);
+public: // actually protected
+ JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::io::OutputStream)))) buf;
+ jint count;
+private:
+ static const jint DEFAULT_INITIAL_BUFFER_SIZE = 32;
+ static jint initial_buffer_size;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ByteArrayOutputStream__
diff --git a/libjava/java/io/CharArrayReader.h b/libjava/java/io/CharArrayReader.h
new file mode 100644
index 000000000..f8b8f5d4c
--- /dev/null
+++ b/libjava/java/io/CharArrayReader.h
@@ -0,0 +1,36 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_CharArrayReader__
+#define __java_io_CharArrayReader__
+
+#pragma interface
+
+#include <java/io/Reader.h>
+#include <gcj/array.h>
+
+
+class java::io::CharArrayReader : public ::java::io::Reader
+{
+
+public:
+ CharArrayReader(JArray< jchar > *);
+ CharArrayReader(JArray< jchar > *, jint, jint);
+ virtual void close();
+ virtual void mark(jint);
+ virtual jboolean markSupported();
+ virtual jint read();
+ virtual jint read(JArray< jchar > *, jint, jint);
+ virtual jboolean ready();
+ virtual void reset();
+ virtual jlong skip(jlong);
+public: // actually protected
+ JArray< jchar > * __attribute__((aligned(__alignof__( ::java::io::Reader)))) buf;
+ jint pos;
+ jint markedPos;
+ jint count;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_CharArrayReader__
diff --git a/libjava/java/io/CharArrayWriter.h b/libjava/java/io/CharArrayWriter.h
new file mode 100644
index 000000000..ee3f559a4
--- /dev/null
+++ b/libjava/java/io/CharArrayWriter.h
@@ -0,0 +1,50 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_CharArrayWriter__
+#define __java_io_CharArrayWriter__
+
+#pragma interface
+
+#include <java/io/Writer.h>
+#include <gcj/array.h>
+
+
+class java::io::CharArrayWriter : public ::java::io::Writer
+{
+
+public:
+ CharArrayWriter();
+ CharArrayWriter(jint);
+ virtual void close();
+ virtual void flush();
+ virtual void reset();
+ virtual jint size();
+ virtual JArray< jchar > * toCharArray();
+ virtual ::java::lang::String * toString();
+ virtual void write(jint);
+ virtual void write(JArray< jchar > *, jint, jint);
+ virtual void write(::java::lang::String *, jint, jint);
+ virtual void writeTo(::java::io::Writer *);
+ virtual ::java::io::CharArrayWriter * CharArrayWriter$append(jchar);
+ virtual ::java::io::CharArrayWriter * CharArrayWriter$append(::java::lang::CharSequence *);
+ virtual ::java::io::CharArrayWriter * CharArrayWriter$append(::java::lang::CharSequence *, jint, jint);
+private:
+ void resize(jint);
+public:
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::io::Writer * Writer$append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *);
+ virtual ::java::io::Writer * Writer$append(::java::lang::CharSequence *);
+ virtual ::java::lang::Appendable * append(jchar);
+ virtual ::java::io::Writer * Writer$append(jchar);
+private:
+ static const jint DEFAULT_INITIAL_BUFFER_SIZE = 32;
+public: // actually protected
+ JArray< jchar > * __attribute__((aligned(__alignof__( ::java::io::Writer)))) buf;
+ jint count;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_CharArrayWriter__
diff --git a/libjava/java/io/CharConversionException.h b/libjava/java/io/CharConversionException.h
new file mode 100644
index 000000000..95034a89b
--- /dev/null
+++ b/libjava/java/io/CharConversionException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_CharConversionException__
+#define __java_io_CharConversionException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+
+class java::io::CharConversionException : public ::java::io::IOException
+{
+
+public:
+ CharConversionException();
+ CharConversionException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = -8680016352018427031LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_CharConversionException__
diff --git a/libjava/java/io/Closeable.h b/libjava/java/io/Closeable.h
new file mode 100644
index 000000000..4668f5089
--- /dev/null
+++ b/libjava/java/io/Closeable.h
@@ -0,0 +1,19 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_Closeable__
+#define __java_io_Closeable__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::Closeable : public ::java::lang::Object
+{
+
+public:
+ virtual void close() = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_Closeable__
diff --git a/libjava/java/io/DataInput.h b/libjava/java/io/DataInput.h
new file mode 100644
index 000000000..9cb4952ff
--- /dev/null
+++ b/libjava/java/io/DataInput.h
@@ -0,0 +1,35 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_DataInput__
+#define __java_io_DataInput__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+
+class java::io::DataInput : public ::java::lang::Object
+{
+
+public:
+ virtual jboolean readBoolean() = 0;
+ virtual jbyte readByte() = 0;
+ virtual jint readUnsignedByte() = 0;
+ virtual jchar readChar() = 0;
+ virtual jshort readShort() = 0;
+ virtual jint readUnsignedShort() = 0;
+ virtual jint readInt() = 0;
+ virtual jlong readLong() = 0;
+ virtual jfloat readFloat() = 0;
+ virtual jdouble readDouble() = 0;
+ virtual ::java::lang::String * readLine() = 0;
+ virtual ::java::lang::String * readUTF() = 0;
+ virtual void readFully(JArray< jbyte > *) = 0;
+ virtual void readFully(JArray< jbyte > *, jint, jint) = 0;
+ virtual jint skipBytes(jint) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_DataInput__
diff --git a/libjava/java/io/DataInputStream.h b/libjava/java/io/DataInputStream.h
new file mode 100644
index 000000000..12371ff95
--- /dev/null
+++ b/libjava/java/io/DataInputStream.h
@@ -0,0 +1,56 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_DataInputStream__
+#define __java_io_DataInputStream__
+
+#pragma interface
+
+#include <java/io/FilterInputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::DataInputStream : public ::java::io::FilterInputStream
+{
+
+public:
+ DataInputStream(::java::io::InputStream *);
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual jboolean readBoolean();
+ virtual jbyte readByte();
+ virtual jchar readChar();
+ virtual jdouble readDouble();
+ virtual jfloat readFloat();
+ virtual void readFully(JArray< jbyte > *);
+ virtual void readFully(JArray< jbyte > *, jint, jint);
+ virtual jint readInt();
+ virtual ::java::lang::String * readLine();
+ virtual jlong readLong();
+ virtual jshort readShort();
+ virtual jint readUnsignedByte();
+ virtual jint readUnsignedShort();
+ virtual ::java::lang::String * readUTF();
+ static ::java::lang::String * readUTF(::java::io::DataInput *);
+public: // actually package-private
+ virtual ::java::lang::String * readUTFLong();
+private:
+ static ::java::lang::String * readUTF(::java::io::DataInput *, jint);
+public:
+ virtual jint skipBytes(jint);
+public: // actually package-private
+ static jboolean convertToBoolean(jint);
+ static jbyte convertToByte(jint);
+ static jint convertToUnsignedByte(jint);
+ static jchar convertToChar(JArray< jbyte > *);
+ static jshort convertToShort(JArray< jbyte > *);
+ static jint convertToUnsignedShort(JArray< jbyte > *);
+ static jint convertToInt(JArray< jbyte > *);
+ static jlong convertToLong(JArray< jbyte > *);
+ static ::java::lang::String * convertFromUTF(JArray< jbyte > *);
+ JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::io::FilterInputStream)))) buf;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_DataInputStream__
diff --git a/libjava/java/io/DataOutput.h b/libjava/java/io/DataOutput.h
new file mode 100644
index 000000000..f18f5e454
--- /dev/null
+++ b/libjava/java/io/DataOutput.h
@@ -0,0 +1,34 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_DataOutput__
+#define __java_io_DataOutput__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+
+class java::io::DataOutput : public ::java::lang::Object
+{
+
+public:
+ virtual void writeBoolean(jboolean) = 0;
+ virtual void writeByte(jint) = 0;
+ virtual void writeChar(jint) = 0;
+ virtual void writeShort(jint) = 0;
+ virtual void writeInt(jint) = 0;
+ virtual void writeLong(jlong) = 0;
+ virtual void writeFloat(jfloat) = 0;
+ virtual void writeDouble(jdouble) = 0;
+ virtual void writeBytes(::java::lang::String *) = 0;
+ virtual void writeChars(::java::lang::String *) = 0;
+ virtual void writeUTF(::java::lang::String *) = 0;
+ virtual void write(jint) = 0;
+ virtual void write(JArray< jbyte > *) = 0;
+ virtual void write(JArray< jbyte > *, jint, jint) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_DataOutput__
diff --git a/libjava/java/io/DataOutputStream.h b/libjava/java/io/DataOutputStream.h
new file mode 100644
index 000000000..aebd234db
--- /dev/null
+++ b/libjava/java/io/DataOutputStream.h
@@ -0,0 +1,49 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_DataOutputStream__
+#define __java_io_DataOutputStream__
+
+#pragma interface
+
+#include <java/io/FilterOutputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::DataOutputStream : public ::java::io::FilterOutputStream
+{
+
+public:
+ DataOutputStream(::java::io::OutputStream *);
+ virtual void flush();
+ virtual jint size();
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual void writeBoolean(jboolean);
+ virtual void writeByte(jint);
+ virtual void writeShort(jint);
+ virtual void writeChar(jint);
+ virtual void writeInt(jint);
+ virtual void writeLong(jlong);
+ virtual void writeFloat(jfloat);
+ virtual void writeDouble(jdouble);
+ virtual void writeBytes(::java::lang::String *);
+ virtual void writeChars(::java::lang::String *);
+public: // actually package-private
+ virtual jlong getUTFlength(::java::lang::String *, jint, jlong);
+public:
+ virtual void writeUTF(::java::lang::String *);
+public: // actually package-private
+ virtual void writeUTFShort(::java::lang::String *, jint);
+ virtual void writeUTFLong(::java::lang::String *, jlong);
+private:
+ void writeUTFBytes(::java::lang::String *);
+public: // actually protected
+ jint __attribute__((aligned(__alignof__( ::java::io::FilterOutputStream)))) written;
+private:
+ JArray< jbyte > * buf;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_DataOutputStream__
diff --git a/libjava/java/io/DeleteFileHelper$1.h b/libjava/java/io/DeleteFileHelper$1.h
new file mode 100644
index 000000000..79c20f3d5
--- /dev/null
+++ b/libjava/java/io/DeleteFileHelper$1.h
@@ -0,0 +1,21 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_DeleteFileHelper$1__
+#define __java_io_DeleteFileHelper$1__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::DeleteFileHelper$1 : public ::java::lang::Object
+{
+
+public: // actually package-private
+ DeleteFileHelper$1();
+public:
+ virtual ::java::lang::Object * run();
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_DeleteFileHelper$1__
diff --git a/libjava/java/io/DeleteFileHelper.h b/libjava/java/io/DeleteFileHelper.h
new file mode 100644
index 000000000..9b61c3aab
--- /dev/null
+++ b/libjava/java/io/DeleteFileHelper.h
@@ -0,0 +1,28 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_DeleteFileHelper__
+#define __java_io_DeleteFileHelper__
+
+#pragma interface
+
+#include <java/lang/Thread.h>
+
+class java::io::DeleteFileHelper : public ::java::lang::Thread
+{
+
+public: // actually package-private
+ static void add(::java::io::File *);
+private:
+ static void deleteFiles();
+public: // actually package-private
+ DeleteFileHelper();
+public:
+ void run();
+private:
+ static ::java::util::ArrayList * filesToDelete;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_DeleteFileHelper__
diff --git a/libjava/java/io/EOFException.h b/libjava/java/io/EOFException.h
new file mode 100644
index 000000000..be4b255e7
--- /dev/null
+++ b/libjava/java/io/EOFException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_EOFException__
+#define __java_io_EOFException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+
+class java::io::EOFException : public ::java::io::IOException
+{
+
+public:
+ EOFException();
+ EOFException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = 6433858223774886977LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_EOFException__
diff --git a/libjava/java/io/Externalizable.h b/libjava/java/io/Externalizable.h
new file mode 100644
index 000000000..b74cf0860
--- /dev/null
+++ b/libjava/java/io/Externalizable.h
@@ -0,0 +1,20 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_Externalizable__
+#define __java_io_Externalizable__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::Externalizable : public ::java::lang::Object
+{
+
+public:
+ virtual void readExternal(::java::io::ObjectInput *) = 0;
+ virtual void writeExternal(::java::io::ObjectOutput *) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_Externalizable__
diff --git a/libjava/java/io/File.h b/libjava/java/io/File.h
new file mode 100644
index 000000000..b53f6ab7d
--- /dev/null
+++ b/libjava/java/io/File.h
@@ -0,0 +1,164 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_File__
+#define __java_io_File__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace java
+ {
+ namespace net
+ {
+ class URI;
+ class URL;
+ }
+ }
+}
+
+class java::io::File : public ::java::lang::Object
+{
+
+ jlong attr(jint);
+ jboolean _access(jint);
+ jboolean _stat(jint);
+ static void init_native();
+public:
+ virtual jboolean canRead();
+ virtual jboolean canWrite();
+ virtual jboolean canExecute();
+private:
+ jboolean performCreate();
+public:
+ virtual jboolean createNewFile();
+private:
+ jboolean performDelete();
+public:
+ virtual jboolean delete$();
+ virtual jboolean equals(::java::lang::Object *);
+private:
+ jboolean internalExists();
+public:
+ virtual jboolean exists();
+ File(::java::lang::String *);
+private:
+ ::java::lang::String * normalizePath(::java::lang::String *);
+public:
+ File(::java::lang::String *, ::java::lang::String *);
+ File(::java::io::File *, ::java::lang::String *);
+ File(::java::net::URI *);
+ virtual ::java::lang::String * getAbsolutePath();
+ virtual ::java::io::File * getAbsoluteFile();
+ virtual ::java::lang::String * getCanonicalPath();
+ virtual ::java::io::File * getCanonicalFile();
+ virtual ::java::lang::String * getName();
+ virtual ::java::lang::String * getParent();
+ virtual ::java::io::File * getParentFile();
+ virtual ::java::lang::String * getPath();
+ virtual jint hashCode();
+ virtual jboolean isAbsolute();
+private:
+ jboolean internalIsDirectory();
+public:
+ virtual jboolean isDirectory();
+ virtual jboolean isFile();
+ virtual jboolean isHidden();
+ virtual jlong lastModified();
+ virtual jlong length();
+private:
+ JArray< ::java::lang::Object * > * performList(::java::io::FilenameFilter *, ::java::io::FileFilter *, ::java::lang::Class *);
+public:
+ virtual JArray< ::java::lang::String * > * list(::java::io::FilenameFilter *);
+ virtual JArray< ::java::lang::String * > * list();
+ virtual JArray< ::java::io::File * > * listFiles();
+ virtual JArray< ::java::io::File * > * listFiles(::java::io::FilenameFilter *);
+ virtual JArray< ::java::io::File * > * listFiles(::java::io::FileFilter *);
+ virtual ::java::lang::String * toString();
+ virtual ::java::net::URI * toURI();
+ virtual ::java::net::URL * toURL();
+private:
+ jboolean performMkdir();
+public:
+ virtual jboolean mkdir();
+private:
+ static jboolean mkdirs(::java::io::File *);
+public:
+ virtual jboolean mkdirs();
+private:
+ static ::java::lang::String * nextValue();
+public:
+ static ::java::io::File * createTempFile(::java::lang::String *, ::java::lang::String *, ::java::io::File *);
+private:
+ jboolean setFilePermissions(jboolean, jboolean, jint);
+public:
+ virtual jboolean setReadable(jboolean);
+ virtual jboolean setReadable(jboolean, jboolean);
+ virtual jboolean setWritable(jboolean);
+ virtual jboolean setWritable(jboolean, jboolean);
+ virtual jboolean setExecutable(jboolean);
+ virtual jboolean setExecutable(jboolean, jboolean);
+private:
+ jboolean performSetReadOnly();
+public:
+ virtual jboolean setReadOnly();
+private:
+ static JArray< ::java::io::File * > * performListRoots();
+public:
+ static JArray< ::java::io::File * > * listRoots();
+ static ::java::io::File * createTempFile(::java::lang::String *, ::java::lang::String *);
+ virtual jint File$compareTo(::java::io::File *);
+private:
+ jboolean performRenameTo(::java::io::File *);
+public:
+ virtual jboolean renameTo(::java::io::File *);
+private:
+ jboolean performSetLastModified(jlong);
+public:
+ virtual jboolean setLastModified(jlong);
+private:
+ void checkWrite();
+ void checkRead();
+ void checkExec();
+public:
+ virtual void deleteOnExit();
+private:
+ void writeObject(::java::io::ObjectOutputStream *);
+ void readObject(::java::io::ObjectInputStream *);
+public:
+ virtual jint compareTo(::java::lang::Object *);
+private:
+ static const jlong serialVersionUID = 301077366599181567LL;
+ static const jint READ = 0;
+ static const jint WRITE = 1;
+ static const jint EXISTS = 2;
+ static const jint EXEC = 3;
+ static const jint DIRECTORY = 0;
+ static const jint ISFILE = 1;
+ static const jint ISHIDDEN = 2;
+ static const jint MODIFIED = 0;
+ static const jint LENGTH = 1;
+public:
+ static ::java::lang::String * separator;
+private:
+ static ::java::lang::String * dupSeparator;
+public:
+ static jchar separatorChar;
+ static ::java::lang::String * pathSeparator;
+ static jchar pathSeparatorChar;
+public: // actually package-private
+ static ::java::lang::String * tmpdir;
+ static jint maxPathLen;
+ static jboolean caseSensitive;
+private:
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) path;
+ static jlong counter;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_File__
diff --git a/libjava/java/io/File.java b/libjava/java/io/File.java
new file mode 100644
index 000000000..0c4fb6932
--- /dev/null
+++ b/libjava/java/io/File.java
@@ -0,0 +1,1579 @@
+/* File.java -- Class representing a file on disk
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import gnu.classpath.Configuration;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * Status: Complete to version 1.3.
+ */
+
+/**
+ * This class represents a file or directory on a local disk. It provides
+ * facilities for dealing with a variety of systems that use various
+ * types of path separators ("/" versus "\", for example). It also
+ * contains method useful for creating and deleting files and directories.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Tom Tromey (tromey@cygnus.com)
+ */
+public class File implements Serializable, Comparable<File>
+{
+ private static final long serialVersionUID = 301077366599181567L;
+
+ // QUERY arguments to access function.
+ private final static int READ = 0;
+ private final static int WRITE = 1;
+ private final static int EXISTS = 2;
+ private final static int EXEC = 3;
+
+ // QUERY arguments to stat function.
+ private final static int DIRECTORY = 0;
+ private final static int ISFILE = 1;
+ private final static int ISHIDDEN = 2;
+
+ // QUERY arguments to attr function.
+ private final static int MODIFIED = 0;
+ private final static int LENGTH = 1;
+
+ private final native long attr (int query);
+ // On OSF1 V5.0, `stat' is a macro. It is easiest to use the name
+ // `_stat' instead. We do the same thing for `_access' just in
+ // case.
+ private final native boolean _access (int query);
+ private final native boolean _stat (int query);
+
+ /**
+ * This is the path separator string for the current host. This field
+ * contains the value of the <code>file.separator</code> system property.
+ * An example separator string would be "/" on the GNU system.
+ */
+ public static final String separator = System.getProperty("file.separator");
+ private static final String dupSeparator = separator + separator;
+
+ /**
+ * This is the first character of the file separator string. On many
+ * hosts (for example, on the GNU system), this represents the entire
+ * separator string. The complete separator string is obtained from the
+ * <code>file.separator</code>system property.
+ */
+ public static final char separatorChar = separator.charAt(0);
+
+ /**
+ * This is the string that is used to separate the host name from the
+ * path name in paths that include the host name. It is the value of
+ * the <code>path.separator</code> system property.
+ */
+ public static final String pathSeparator
+ = System.getProperty("path.separator");
+
+ /**
+ * This is the first character of the string used to separate the host name
+ * from the path name in paths that include a host. The separator string
+ * is taken from the <code>path.separator</code> system property.
+ */
+ public static final char pathSeparatorChar = pathSeparator.charAt(0);
+
+ static final String tmpdir = System.getProperty("java.io.tmpdir");
+ /* If 0, then the system doesn't have a file name length limit. */
+ static int maxPathLen;
+ static boolean caseSensitive;
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary("javaio");
+ }
+
+ init_native();
+ }
+
+ // Native function called at class initialization. This should should
+ // set the maxPathLen and caseSensitive variables.
+ private static native void init_native();
+
+ /**
+ * This is the path to the file set when the object is created. It
+ * may be an absolute or relative path name.
+ */
+ private String path;
+
+ // We keep a counter for use by createTempFile. We choose the first
+ // value randomly to try to avoid clashes with other VMs.
+ private static long counter = Double.doubleToLongBits (Math.random());
+
+ /**
+ * This method tests whether or not the current thread is allowed to
+ * to read the file pointed to by this object. This will be true if and
+ * and only if 1) the file exists and 2) the <code>SecurityManager</code>
+ * (if any) allows access to the file via it's <code>checkRead</code>
+ * method 3) the file is readable.
+ *
+ * @return <code>true</code> if reading is allowed,
+ * <code>false</code> otherwise
+ *
+ * @exception SecurityException If the <code>SecurityManager</code>
+ * does not allow access to the file
+ */
+ public boolean canRead()
+ {
+ checkRead();
+ return _access (READ);
+ }
+
+ /**
+ * This method test whether or not the current thread is allowed to
+ * write to this object. This will be true if and only if 1) The
+ * <code>SecurityManager</code> (if any) allows write access to the
+ * file and 2) The file exists and 3) The file is writable. To determine
+ * whether or not a non-existent file can be created, check the parent
+ * directory for write access.
+ *
+ * @return <code>true</code> if writing is allowed, <code>false</code>
+ * otherwise
+ *
+ * @exception SecurityException If the <code>SecurityManager</code>
+ * does not allow access to the file
+ */
+ public boolean canWrite()
+ {
+ checkWrite();
+ return _access (WRITE);
+ }
+
+ /**
+ * This method tests whether or not the current thread is allowed to
+ * to execute the file pointed to by this object. This will be true if and
+ * and only if 1) the file exists and 2) the <code>SecurityManager</code>
+ * (if any) allows access to the file via it's <code>checkExec</code>
+ * method 3) the file is executable.
+ *
+ * @return <code>true</code> if execution is allowed,
+ * <code>false</code> otherwise
+ *
+ * @exception SecurityException If the <code>SecurityManager</code>
+ * does not allow access to the file
+ */
+ public boolean canExecute()
+ {
+ if (!exists())
+ return false;
+ checkExec();
+ return _access (EXEC);
+ }
+
+ private native boolean performCreate() throws IOException;
+
+ /**
+ * This method creates a new file of zero length with the same name as
+ * the path of this <code>File</code> object if an only if that file
+ * does not already exist.
+ * <p>
+ * A <code>SecurityManager.checkWrite</code> check is done prior
+ * to performing this action.
+ *
+ * @return <code>true</code> if the file was created, <code>false</code> if
+ * the file alread existed.
+ *
+ * @exception IOException If an I/O error occurs
+ * @exception SecurityException If the <code>SecurityManager</code> will
+ * not allow this operation to be performed.
+ *
+ * @since 1.2
+ */
+ public boolean createNewFile() throws IOException
+ {
+ checkWrite();
+ return performCreate();
+ }
+
+ /*
+ * This native method handles the actual deleting of the file
+ */
+ private native boolean performDelete();
+
+ /**
+ * This method deletes the file represented by this object. If this file
+ * is a directory, it must be empty in order for the delete to succeed.
+ *
+ * @return <code>true</code> if the file was deleted, <code>false</code>
+ * otherwise
+ *
+ * @exception SecurityException If deleting of the file is not allowed
+ */
+ public synchronized boolean delete()
+ {
+ SecurityManager s = System.getSecurityManager();
+
+ if (s != null)
+ s.checkDelete(path);
+
+ return performDelete();
+ }
+
+ /**
+ * This method tests two <code>File</code> objects for equality by
+ * comparing the path of the specified <code>File</code> against the path
+ * of this object. The two objects are equal if an only if 1) The
+ * argument is not null 2) The argument is a <code>File</code> object and
+ * 3) The path of the <code>File</code>argument is equal to the path
+ * of this object.
+ * <p>
+ * The paths of the files are determined by calling the
+ * <code>getPath()</code>
+ * method on each object.
+ *
+ * @return <code>true</code> if the two objects are equal,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (! (obj instanceof File))
+ return false;
+
+ File other = (File) obj;
+
+ if (caseSensitive)
+ return path.equals(other.path);
+ else
+ return path.equalsIgnoreCase(other.path);
+ }
+
+ /*
+ * This method tests whether or not the file represented by the
+ * object actually exists on the filesystem.
+ */
+ private boolean internalExists()
+ {
+ return _access (EXISTS);
+ }
+
+ /**
+ * This method tests whether or not the file represented by the object
+ * actually exists on the filesystem.
+ *
+ * @return <code>true</code> if the file exists, <code>false</code>otherwise.
+ *
+ * @exception SecurityException If reading of the file is not permitted
+ */
+ public boolean exists()
+ {
+ checkRead();
+ return internalExists();
+ }
+
+ /**
+ * This method initializes a new <code>File</code> object to represent
+ * a file with the specified path.
+ *
+ * @param name The path name of the file
+ */
+ public File(String name)
+ {
+ path = normalizePath (name);
+ }
+
+ // Remove duplicate and redundant separator characters.
+ private String normalizePath(String p)
+ {
+ // On Windows, convert any '/' to '\'. This appears to be the same logic
+ // that Sun's Win32 Java performs.
+ if (separatorChar == '\\')
+ {
+ p = p.replace ('/', '\\');
+ // We have to special case the "\c:" prefix.
+ if (p.length() > 2 && p.charAt(0) == '\\' &&
+ ((p.charAt(1) >= 'a' && p.charAt(1) <= 'z') ||
+ (p.charAt(1) >= 'A' && p.charAt(1) <= 'Z')) &&
+ p.charAt(2) == ':')
+ p = p.substring(1);
+ }
+
+ int dupIndex = p.indexOf(dupSeparator);
+ int plen = p.length();
+
+ // Special case: permit Windows UNC path prefix.
+ if (dupSeparator.equals("\\\\") && dupIndex == 0)
+ dupIndex = p.indexOf(dupSeparator, 1);
+
+ if (dupIndex == -1)
+ {
+ // Ignore trailing separator (though on Windows "a:\", for
+ // example, is a valid and minimal path).
+ if (plen > 1 && p.charAt (plen - 1) == separatorChar)
+ {
+ if (! (separatorChar == '\\' && plen == 3 && p.charAt (1) == ':'))
+ return p.substring (0, plen - 1);
+ }
+ else
+ return p;
+ }
+
+ StringBuffer newpath = new StringBuffer(plen);
+ int last = 0;
+ while (dupIndex != -1)
+ {
+ newpath.append(p.substring(last, dupIndex));
+ // Ignore the duplicate path characters.
+ while (p.charAt(dupIndex) == separatorChar)
+ {
+ dupIndex++;
+ if (dupIndex == plen)
+ return newpath.toString();
+ }
+ newpath.append(separatorChar);
+ last = dupIndex;
+ dupIndex = p.indexOf(dupSeparator, last);
+ }
+
+ // Again, ignore possible trailing separator (except special cases
+ // like "a:\" on Windows).
+ int end;
+ if (plen > 1 && p.charAt (plen - 1) == separatorChar)
+ {
+ if (separatorChar == '\\' && plen == 3 && p.charAt (1) == ':')
+ end = plen;
+ else
+ end = plen - 1;
+ }
+ else
+ end = plen;
+ newpath.append(p.substring(last, end));
+
+ return newpath.toString();
+ }
+
+ /**
+ * This method initializes a new <code>File</code> object to represent
+ * a file in the specified named directory. The path name to the file
+ * will be the directory name plus the separator string plus the file
+ * name. If the directory path name ends in the separator string, another
+ * separator string will still be appended.
+ *
+ * @param dirPath The path to the directory the file resides in
+ * @param name The name of the file
+ */
+ public File(String dirPath, String name)
+ {
+ if (name == null)
+ throw new NullPointerException();
+ if (dirPath != null)
+ {
+ if (dirPath.length() > 0)
+ {
+ // Try to be smart about the number of separator characters.
+ if (dirPath.charAt(dirPath.length() - 1) == separatorChar
+ || name.length() == 0)
+ path = normalizePath(dirPath + name);
+ else
+ path = normalizePath(dirPath + separatorChar + name);
+ }
+ else
+ {
+ // If dirPath is empty, use a system dependant
+ // default prefix.
+ // Note that the leading separators in name have
+ // to be chopped off, to prevent them forming
+ // a UNC prefix on Windows.
+ if (separatorChar == '\\' /* TODO use ON_WINDOWS */)
+ {
+ int skip = 0;
+ while(name.length() > skip
+ && (name.charAt(skip) == separatorChar
+ || name.charAt(skip) == '/'))
+ {
+ skip++;
+ }
+ name = name.substring(skip);
+ }
+ path = normalizePath(separatorChar + name);
+ }
+ }
+ else
+ path = normalizePath(name);
+ }
+
+ /**
+ * This method initializes a new <code>File</code> object to represent
+ * a file in the specified directory. If the <code>directory</code>
+ * argument is <code>null</code>, the file is assumed to be in the
+ * current directory as specified by the <code>user.dir</code> system
+ * property
+ *
+ * @param directory The directory this file resides in
+ * @param name The name of the file
+ */
+ public File(File directory, String name)
+ {
+ this (directory == null ? null : directory.path, name);
+ }
+
+ /**
+ * This method initializes a new <code>File</code> object to represent
+ * a file corresponding to the specified <code>file:</code> protocol URI.
+ *
+ * @param uri The URI
+ * @throws IllegalArgumentException if the URI is not hierarchical
+ */
+ public File(URI uri)
+ {
+ if (uri == null)
+ throw new NullPointerException("uri is null");
+
+ if (!uri.getScheme().equals("file"))
+ throw new IllegalArgumentException("invalid uri protocol");
+
+ String name = uri.getPath();
+ if (name == null)
+ throw new IllegalArgumentException("URI \"" + uri
+ + "\" is not hierarchical");
+ path = normalizePath(name);
+ }
+
+ /**
+ * This method returns the path of this file as an absolute path name.
+ * If the path name is already absolute, then it is returned. Otherwise
+ * the value returned is the current directory plus the separatory
+ * string plus the path of the file. The current directory is determined
+ * from the <code>user.dir</code> system property.
+ *
+ * @return The absolute path of this file
+ */
+ public String getAbsolutePath()
+ {
+ if (isAbsolute())
+ return path;
+ else if (separatorChar == '\\'
+ && path.length() > 0 && path.charAt (0) == '\\')
+ {
+ // On Windows, even if the path starts with a '\\' it is not
+ // really absolute until we prefix the drive specifier from
+ // the current working directory to it.
+ return System.getProperty ("user.dir").substring (0, 2) + path;
+ }
+ else if (separatorChar == '\\'
+ && path.length() > 1 && path.charAt (1) == ':'
+ && ((path.charAt (0) >= 'a' && path.charAt (0) <= 'z')
+ || (path.charAt (0) >= 'A' && path.charAt (0) <= 'Z')))
+ {
+ // On Windows, a process has a current working directory for
+ // each drive and a path like "G:foo\bar" would mean the
+ // absolute path "G:\wombat\foo\bar" if "\wombat" is the
+ // working directory on the G drive.
+ String drvDir = null;
+ try
+ {
+ drvDir = new File (path.substring (0, 2)).getCanonicalPath();
+ }
+ catch (IOException e)
+ {
+ drvDir = path.substring (0, 2) + "\\";
+ }
+
+ // Note: this would return "C:\\." for the path "C:.", if "\"
+ // is the working folder on the C drive, but this is
+ // consistent with what Sun's JRE 1.4.1.01 actually returns!
+ if (path.length() > 2)
+ return drvDir + '\\' + path.substring (2, path.length());
+ else
+ return drvDir;
+ }
+ else
+ return System.getProperty ("user.dir") + separatorChar + path;
+ }
+
+ /**
+ * This method returns a <code>File</code> object representing the
+ * absolute path of this object.
+ *
+ * @return A <code>File</code> with the absolute path of the object.
+ *
+ * @since 1.2
+ */
+ public File getAbsoluteFile()
+ {
+ return new File(getAbsolutePath());
+ }
+
+ /**
+ * This method returns a canonical representation of the pathname of
+ * this file. The actual form of the canonical representation is
+ * system-dependent. On the GNU system, conversion to canonical
+ * form involves the removal of redundant separators, references to
+ * "." and "..", and symbolic links.
+ * <p>
+ * Note that this method, unlike the other methods which return path
+ * names, can throw an IOException. This is because native method
+ * might be required in order to resolve the canonical path
+ *
+ * @exception IOException If an error occurs
+ */
+ public native String getCanonicalPath() throws IOException;
+
+ /**
+ * This method returns a <code>File</code> object representing the
+ * canonical path of this object.
+ *
+ * @return A <code>File</code> instance representing the canonical path of
+ * this object.
+ *
+ * @exception IOException If an error occurs.
+ *
+ * @since 1.2
+ */
+ public File getCanonicalFile() throws IOException
+ {
+ return new File(getCanonicalPath());
+ }
+
+ /**
+ * This method returns the name of the file. This is everything in the
+ * complete path of the file after the last instance of the separator
+ * string.
+ *
+ * @return The file name
+ */
+ public String getName()
+ {
+ int nameSeqIndex = 0;
+
+ if (separatorChar == '\\' && path.length() > 1)
+ {
+ // On Windows, ignore the drive specifier or the leading '\\'
+ // of a UNC network path, if any (a.k.a. the "prefix").
+ if ((path.charAt (0) == '\\' && path.charAt (1) == '\\')
+ || (((path.charAt (0) >= 'a' && path.charAt (0) <= 'z')
+ || (path.charAt (0) >= 'A' && path.charAt (0) <= 'Z'))
+ && path.charAt (1) == ':'))
+ {
+ if (path.length() > 2)
+ nameSeqIndex = 2;
+ else
+ return "";
+ }
+ }
+
+ String nameSeq
+ = (nameSeqIndex > 0 ? path.substring (nameSeqIndex) : path);
+
+ int last = nameSeq.lastIndexOf (separatorChar);
+
+ return nameSeq.substring (last + 1);
+ }
+
+ /**
+ * This method returns a <code>String</code> the represents this file's
+ * parent. <code>null</code> is returned if the file has no parent. The
+ * parent is determined via a simple operation which removes the name
+ * after the last file separator character, as determined by the platform.
+ *
+ * @return The parent directory of this file
+ */
+ public String getParent()
+ {
+ String prefix = null;
+ int nameSeqIndex = 0;
+
+ // The "prefix", if present, is the leading "/" on UNIX and
+ // either the drive specifier (e.g. "C:") or the leading "\\"
+ // of a UNC network path on Windows.
+ if (separatorChar == '/' && path.charAt (0) == '/')
+ {
+ prefix = "/";
+ nameSeqIndex = 1;
+ }
+ else if (separatorChar == '\\' && path.length() > 1)
+ {
+ if ((path.charAt (0) == '\\' && path.charAt (1) == '\\')
+ || (((path.charAt (0) >= 'a' && path.charAt (0) <= 'z')
+ || (path.charAt (0) >= 'A' && path.charAt (0) <= 'Z'))
+ && path.charAt (1) == ':'))
+ {
+ prefix = path.substring (0, 2);
+ nameSeqIndex = 2;
+ }
+ }
+
+ // According to the JDK docs, the returned parent path is the
+ // portion of the name sequence before the last separator
+ // character, if found, prefixed by the prefix, otherwise null.
+ if (nameSeqIndex < path.length())
+ {
+ String nameSeq = path.substring (nameSeqIndex, path.length());
+ int last = nameSeq.lastIndexOf (separatorChar);
+ if (last == -1)
+ return prefix;
+ else if (last == (nameSeq.length() - 1))
+ // Note: The path would not have a trailing separator
+ // except for cases like "C:\" on Windows (see
+ // normalizePath( )), where Sun's JRE 1.4 returns null.
+ return null;
+ else if (last == 0)
+ last++;
+
+ if (prefix != null)
+ return prefix + nameSeq.substring (0, last);
+ else
+ return nameSeq.substring (0, last);
+ }
+ else
+ // Sun's JRE 1.4 returns null if the prefix is the only
+ // component of the path - so "/" gives null on UNIX and
+ // "C:", "\\", etc. return null on Windows.
+ return null;
+ }
+
+ /**
+ * This method returns a <code>File</code> object representing the parent
+ * file of this one.
+ *
+ * @return a <code>File</code> for the parent of this object.
+ * <code>null</code>
+ * will be returned if this object does not have a parent.
+ *
+ * @since 1.2
+ */
+ public File getParentFile()
+ {
+ String parent = getParent();
+ return parent != null ? new File(parent) : null;
+ }
+
+ /**
+ * Returns the path name that represents this file. May be a relative
+ * or an absolute path name
+ *
+ * @return The pathname of this file
+ */
+ public String getPath()
+ {
+ return path;
+ }
+
+ /**
+ * This method returns a hash code representing this file. It is the
+ * hash code of the path of this file (as returned by <code>getPath()</code>)
+ * exclusived or-ed with the value 1234321.
+ *
+ * @return The hash code for this object
+ */
+ public int hashCode()
+ {
+ if (caseSensitive)
+ return path.hashCode() ^ 1234321;
+ else
+ return path.toLowerCase().hashCode() ^ 1234321;
+ }
+
+ /**
+ * This method returns true if this object represents an absolute file
+ * path and false if it does not. The definition of an absolute path varies
+ * by system. As an example, on GNU systems, a path is absolute if it starts
+ * with a "/".
+ *
+ * @return <code>true</code> if this object represents an absolute
+ * file name, <code>false</code> otherwise.
+ */
+ public native boolean isAbsolute();
+
+ /*
+ * This method tests whether or not the file represented by this
+ * object is a directory.
+ */
+ private boolean internalIsDirectory()
+ {
+ return _stat (DIRECTORY);
+ }
+
+ /**
+ * This method tests whether or not the file represented by this object
+ * is a directory. In order for this method to return <code>true</code>,
+ * the file represented by this object must exist and be a directory.
+ *
+ * @return <code>true</code> if this file is a directory, <code>false</code>
+ * otherwise
+ *
+ * @exception SecurityException If reading of the file is not permitted
+ */
+ public boolean isDirectory()
+ {
+ checkRead();
+ return internalIsDirectory();
+ }
+
+ /**
+ * This method tests whether or not the file represented by this object
+ * is a "plain" file. A file is a plain file if and only if it 1) Exists,
+ * 2) Is not a directory or other type of special file.
+ *
+ * @return <code>true</code> if this is a plain file, <code>false</code>
+ * otherwise
+ *
+ * @exception SecurityException If reading of the file is not permitted
+ */
+ public boolean isFile()
+ {
+ checkRead();
+ return _stat (ISFILE);
+ }
+
+ /**
+ * This method tests whether or not this file represents a "hidden" file.
+ * On GNU systems, a file is hidden if its name begins with a "."
+ * character. Files with these names are traditionally not shown with
+ * directory listing tools.
+ *
+ * @return <code>true</code> if the file is hidden, <code>false</code>
+ * otherwise.
+ *
+ * @since 1.2
+ */
+ public boolean isHidden()
+ {
+ checkRead();
+ return _stat (ISHIDDEN);
+ }
+
+ /**
+ * This method returns the last modification time of this file. The
+ * time value returned is an abstract value that should not be interpreted
+ * as a specified time value. It is only useful for comparing to other
+ * such time values returned on the same system. In that case, the larger
+ * value indicates a more recent modification time.
+ * <p>
+ * If the file does not exist, then a value of 0 is returned.
+ *
+ * @return The last modification time of the file
+ *
+ * @exception SecurityException If reading of the file is not permitted
+ */
+ public long lastModified()
+ {
+ checkRead();
+ return attr (MODIFIED);
+ }
+
+ /**
+ * This method returns the length of the file represented by this object,
+ * or 0 if the specified file does not exist.
+ *
+ * @return The length of the file
+ *
+ * @exception SecurityException If reading of the file is not permitted
+ */
+ public long length()
+ {
+ checkRead();
+ return attr (LENGTH);
+ }
+
+ /*
+ * This native function actually produces the list of file in this
+ * directory
+ */
+ private final native Object[] performList (FilenameFilter filter,
+ FileFilter fileFilter,
+ Class result_type);
+
+ /**
+ * This method returns a array of <code>String</code>'s representing the
+ * list of files is then directory represented by this object. If this
+ * object represents a non-directory file or a non-existent file, then
+ * <code>null</code> is returned. The list of files will not contain
+ * any names such as "." or ".." which indicate the current or parent
+ * directory. Also, the names are not guaranteed to be sorted.
+ * <p>
+ * In this form of the <code>list()</code> method, a filter is specified
+ * that allows the caller to control which files are returned in the
+ * list. The <code>FilenameFilter</code> specified is called for each
+ * file returned to determine whether or not that file should be included
+ * in the list.
+ * <p>
+ * A <code>SecurityManager</code> check is made prior to reading the
+ * directory. If read access to the directory is denied, an exception
+ * will be thrown.
+ *
+ * @param filter An object which will identify files to exclude from
+ * the directory listing.
+ *
+ * @return An array of files in the directory, or <code>null</code>
+ * if this object does not represent a valid directory.
+ *
+ * @exception SecurityException If read access is not allowed to the
+ * directory by the <code>SecurityManager</code>
+ */
+ public String[] list(FilenameFilter filter)
+ {
+ checkRead();
+ return (String[]) performList (filter, null, String.class);
+ }
+
+ /**
+ * This method returns a array of <code>String</code>'s representing the
+ * list of files is then directory represented by this object. If this
+ * object represents a non-directory file or a non-existent file, then
+ * <code>null</code> is returned. The list of files will not contain
+ * any names such as "." or ".." which indicate the current or parent
+ * directory. Also, the names are not guaranteed to be sorted.
+ * <p>
+ * A <code>SecurityManager</code> check is made prior to reading the
+ * directory. If read access to the directory is denied, an exception
+ * will be thrown.
+ *
+ * @return An array of files in the directory, or <code>null</code> if
+ * this object does not represent a valid directory.
+ *
+ * @exception SecurityException If read access is not allowed to the
+ * directory by the <code>SecurityManager</code>
+ */
+ public String[] list()
+ {
+ checkRead();
+ return (String[]) performList (null, null, String.class);
+ }
+
+ /**
+ * This method returns an array of <code>File</code> objects representing
+ * all the files in the directory represented by this object. If this
+ * object does not represent a directory, <code>null</code> is returned.
+ * Each of the returned <code>File</code> object is constructed with this
+ * object as its parent.
+ * <p>
+ * A <code>SecurityManager</code> check is made prior to reading the
+ * directory. If read access to the directory is denied, an exception
+ * will be thrown.
+ *
+ * @return An array of <code>File</code> objects for this directory.
+ *
+ * @exception SecurityException If the <code>SecurityManager</code> denies
+ * access to this directory.
+ *
+ * @since 1.2
+ */
+ public File[] listFiles()
+ {
+ checkRead();
+ return (File[]) performList (null, null, File.class);
+ }
+
+ /**
+ * This method returns an array of <code>File</code> objects representing
+ * all the files in the directory represented by this object. If this
+ * object does not represent a directory, <code>null</code> is returned.
+ * Each of the returned <code>File</code> object is constructed with this
+ * object as its parent.
+ * <p>
+ * In this form of the <code>listFiles()</code> method, a filter is specified
+ * that allows the caller to control which files are returned in the
+ * list. The <code>FilenameFilter</code> specified is called for each
+ * file returned to determine whether or not that file should be included
+ * in the list.
+ * <p>
+ * A <code>SecurityManager</code> check is made prior to reading the
+ * directory. If read access to the directory is denied, an exception
+ * will be thrown.
+ *
+ * @return An array of <code>File</code> objects for this directory.
+ *
+ * @exception SecurityException If the <code>SecurityManager</code> denies
+ * access to this directory.
+ *
+ * @since 1.2
+ */
+ public File[] listFiles(FilenameFilter filter)
+ {
+ checkRead();
+ return (File[]) performList (filter, null, File.class);
+ }
+
+ /**
+ * This method returns an array of <code>File</code> objects representing
+ * all the files in the directory represented by this object. If this
+ * object does not represent a directory, <code>null</code> is returned.
+ * Each of the returned <code>File</code> object is constructed with this
+ * object as its parent.
+ * <p>
+ * In this form of the <code>listFiles()</code> method, a filter is specified
+ * that allows the caller to control which files are returned in the
+ * list. The <code>FileFilter</code> specified is called for each
+ * file returned to determine whether or not that file should be included
+ * in the list.
+ * <p>
+ * A <code>SecurityManager</code> check is made prior to reading the
+ * directory. If read access to the directory is denied, an exception
+ * will be thrown.
+ *
+ * @return An array of <code>File</code> objects for this directory.
+ *
+ * @exception SecurityException If the <code>SecurityManager</code> denies
+ * access to this directory.
+ *
+ * @since 1.2
+ */
+ public File[] listFiles(FileFilter filter)
+ {
+ checkRead();
+ return (File[]) performList (null, filter, File.class);
+ }
+
+ /**
+ * This method returns a <code>String</code> that is the path name of the
+ * file as returned by <code>getPath</code>.
+ *
+ * @return A <code>String</code> representation of this file
+ */
+ public String toString()
+ {
+ return path;
+ }
+
+ /**
+ * @return A <code>URI</code> for this object.
+ */
+ public URI toURI()
+ {
+ String abspath = getAbsolutePath();
+
+ if (isDirectory())
+ abspath = abspath + separator;
+
+ try
+ {
+ return new URI("file", abspath.replace(separatorChar, '/'), null);
+ }
+ catch (URISyntaxException use)
+ {
+ // Can't happen.
+ throw new RuntimeException(use);
+ }
+ }
+
+ /**
+ * This method returns a <code>URL</code> with the <code>file:</code>
+ * protocol that represents this file. The exact form of this URL is
+ * system dependent.
+ *
+ * @return A <code>URL</code> for this object.
+ *
+ * @exception MalformedURLException If the URL cannot be created
+ * successfully.
+ */
+ public URL toURL() throws MalformedURLException
+ {
+ // On Win32, Sun's JDK returns URLs of the form "file:/c:/foo/bar.txt",
+ // while on UNIX, it returns URLs of the form "file:/foo/bar.txt".
+ if (separatorChar == '\\')
+ return new URL ("file:/" + getAbsolutePath().replace ('\\', '/')
+ + (isDirectory() ? "/" : ""));
+ else
+ return new URL ("file:" + getAbsolutePath()
+ + (isDirectory() ? "/" : ""));
+ }
+
+ /*
+ * This native method actually creates the directory
+ */
+ private final native boolean performMkdir();
+
+ /**
+ * This method creates a directory for the path represented by this object.
+ *
+ * @return <code>true</code> if the directory was created,
+ * <code>false</code> otherwise
+ *
+ * @exception SecurityException If write access is not allowed to this file
+ */
+ public boolean mkdir()
+ {
+ checkWrite();
+ return performMkdir();
+ }
+
+ private static boolean mkdirs (File x)
+ {
+ if (x.isDirectory())
+ return true;
+ String p = x.getPath();
+ String parent = x.getParent();
+ if (parent != null)
+ {
+ x.path = parent;
+ if (! mkdirs (x))
+ return false;
+ x.path = p;
+ }
+ return x.mkdir();
+ }
+
+ /**
+ * This method creates a directory for the path represented by this file.
+ * It will also create any intervening parent directories if necessary.
+ *
+ * @return <code>true</code> if the directory was created,
+ * <code>false</code> otherwise
+ *
+ * @exception SecurityException If write access is not allowed to this file
+ */
+ public boolean mkdirs()
+ {
+ checkWrite();
+ if (isDirectory())
+ return false;
+ return mkdirs (new File (path));
+ }
+
+ private static synchronized String nextValue()
+ {
+ return Long.toString(counter++, Character.MAX_RADIX);
+ }
+
+ /**
+ * This method creates a temporary file in the specified directory. If
+ * the directory name is null, then this method uses the system temporary
+ * directory. The files created are guaranteed not to currently exist and
+ * the same file name will never be used twice in the same virtual
+ * machine instance.
+ * The system temporary directory is determined by examinging the
+ * <code>java.io.tmpdir</code> system property.
+ * <p>
+ * The <code>prefix</code> parameter is a sequence of at least three
+ * characters that are used as the start of the generated filename. The
+ * <code>suffix</code> parameter is a sequence of characters that is used
+ * to terminate the file name. This parameter may be <code>null</code>
+ * and if it is, the suffix defaults to ".tmp".
+ * <p>
+ * If a <code>SecurityManager</code> exists, then its <code>checkWrite</code>
+ * method is used to verify that this operation is permitted.
+ *
+ * @param prefix The character prefix to use in generating the path name.
+ * @param suffix The character suffix to use in generating the path name.
+ * @param directory The directory to create the file in, or
+ * <code>null</code> for the default temporary directory
+ *
+ * @exception IllegalArgumentException If the patterns is not valid
+ * @exception SecurityException If there is no permission to perform
+ * this operation
+ * @exception IOException If an error occurs
+ *
+ * @since 1.2
+ */
+ public static File createTempFile(String prefix, String suffix,
+ File directory)
+ throws IOException
+ {
+ // Grab the system temp directory if necessary
+ if (directory == null)
+ {
+ String dirname = tmpdir;
+ if (dirname == null)
+ throw new IOException("Cannot determine system temporary directory");
+
+ directory = new File(dirname);
+ if (!directory.internalExists())
+ throw new IOException("System temporary directory "
+ + directory.getName() + " does not exist.");
+ if (!directory.internalIsDirectory())
+ throw new IOException("System temporary directory "
+ + directory.getName()
+ + " is not really a directory.");
+ }
+
+ // Check if prefix is at least 3 characters long
+ if (prefix.length() < 3)
+ throw new IllegalArgumentException("Prefix too short: " + prefix);
+
+ // Set default value of suffix
+ if (suffix == null)
+ suffix = ".tmp";
+
+ // Truncation rules.
+ // `6' is the number of characters we generate.
+ // If maxPathLen equals zero, then the system doesn't have a limit
+ // on the file name, so there is nothing to truncate.
+ if (maxPathLen > 0 && prefix.length() + 6 + suffix.length() > maxPathLen)
+ {
+ int suf_len = 0;
+ if (suffix.charAt(0) == '.')
+ suf_len = 4;
+ suffix = suffix.substring(0, suf_len);
+ if (prefix.length() + 6 + suf_len > maxPathLen)
+ prefix = prefix.substring(0, maxPathLen - 6 - suf_len);
+ }
+
+ File f;
+
+ // How many times should we try? We choose 100.
+ for (int i = 0; i < 100; ++i)
+ {
+ // This is ugly.
+ String t = "ZZZZZZ" + nextValue();
+ String l = prefix + t.substring(t.length() - 6) + suffix;
+ try
+ {
+ f = new File(directory, l);
+ if (f.createNewFile())
+ return f;
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+
+ throw new IOException ("cannot create temporary file");
+ }
+
+ /*
+ * This native method sets file permissions.
+ */
+ private native boolean setFilePermissions(boolean enable, boolean ownerOnly,
+ int permissions);
+
+ /**
+ * This method sets the owner's read permission for the File represented by
+ * this object.
+ *
+ * It is the same as calling <code>setReadable(readable, true)</code>.
+ *
+ * @param <code>readable</code> <code>true</code> to set read permission,
+ * <code>false</code> to unset the read permission.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setReadable(boolean, boolean)
+ * @since 1.6
+ */
+ public boolean setReadable(boolean readable)
+ {
+ return setReadable(readable, true);
+ }
+
+ /**
+ * This method sets the read permissions for the File represented by
+ * this object.
+ *
+ * If <code>ownerOnly</code> is set to <code>true</code> then only the
+ * read permission bit for the owner of the file is changed.
+ *
+ * If <code>ownerOnly</code> is set to <code>false</code>, the file
+ * permissions are changed so that the file can be read by everyone.
+ *
+ * On unix like systems this sets the <code>user</code>, <code>group</code>
+ * and <code>other</code> read bits and is equal to call
+ * <code>chmod a+r</code> on the file.
+ *
+ * @param <code>readable</code> <code>true</code> to set read permission,
+ * <code>false</code> to unset the read permission.
+ * @param <code>ownerOnly</code> <code>true</code> to set read permission
+ * for owner only, <code>false</code> for all.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setReadable(boolean)
+ * @since 1.6
+ */
+ public boolean setReadable(boolean readable, boolean ownerOnly)
+ {
+ checkWrite();
+ return setFilePermissions(readable, ownerOnly, READ);
+ }
+
+ /**
+ * This method sets the owner's write permission for the File represented by
+ * this object.
+ *
+ * It is the same as calling <code>setWritable(readable, true)</code>.
+ *
+ * @param <code>writable</code> <code>true</code> to set write permission,
+ * <code>false</code> to unset write permission.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setWritable(boolean, boolean)
+ * @since 1.6
+ */
+ public boolean setWritable(boolean writable)
+ {
+ return setWritable(writable, true);
+ }
+
+ /**
+ * This method sets the write permissions for the File represented by
+ * this object.
+ *
+ * If <code>ownerOnly</code> is set to <code>true</code> then only the
+ * write permission bit for the owner of the file is changed.
+ *
+ * If <code>ownerOnly</code> is set to <code>false</code>, the file
+ * permissions are changed so that the file can be written by everyone.
+ *
+ * On unix like systems this set the <code>user</code>, <code>group</code>
+ * and <code>other</code> write bits and is equal to call
+ * <code>chmod a+w</code> on the file.
+ *
+ * @param <code>writable</code> <code>true</code> to set write permission,
+ * <code>false</code> to unset write permission.
+ * @param <code>ownerOnly</code> <code>true</code> to set write permission
+ * for owner only, <code>false</code> for all.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setWritable(boolean)
+ * @since 1.6
+ */
+ public boolean setWritable(boolean writable, boolean ownerOnly)
+ {
+ checkWrite();
+ return setFilePermissions(writable, ownerOnly, WRITE);
+ }
+
+ /**
+ * This method sets the owner's execute permission for the File represented
+ * by this object.
+ *
+ * It is the same as calling <code>setExecutable(readable, true)</code>.
+ *
+ * @param <code>executable</code> <code>true</code> to set execute permission,
+ * <code>false</code> to unset execute permission.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setExecutable(boolean, boolean)
+ * @since 1.6
+ */
+ public boolean setExecutable(boolean executable)
+ {
+ return setExecutable(executable, true);
+ }
+
+ /**
+ * This method sets the execute permissions for the File represented by
+ * this object.
+ *
+ * If <code>ownerOnly</code> is set to <code>true</code> then only the
+ * execute permission bit for the owner of the file is changed.
+ *
+ * If <code>ownerOnly</code> is set to <code>false</code>, the file
+ * permissions are changed so that the file can be executed by everyone.
+ *
+ * On unix like systems this set the <code>user</code>, <code>group</code>
+ * and <code>other</code> write bits and is equal to call
+ * <code>chmod a+x</code> on the file.
+ *
+ * @param <code>executable</code> <code>true</code> to set write permission,
+ * <code>false</code> to unset write permission.
+ * @param <code>ownerOnly</code> <code>true</code> to set write permission
+ * for owner only, <code>false</code> for all.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setExecutable(boolean)
+ * @since 1.6
+ */
+ public boolean setExecutable(boolean executable, boolean ownerOnly)
+ {
+ checkWrite();
+ return setFilePermissions(executable, ownerOnly, EXEC);
+ }
+
+ /*
+ * This native method sets the permissions to make the file read only.
+ */
+ private native boolean performSetReadOnly();
+
+ /**
+ * This method sets the file represented by this object to be read only.
+ * A read only file or directory cannot be modified. Please note that
+ * GNU systems allow read only files to be deleted if the directory it
+ * is contained in is writable.
+ *
+ * @return <code>true</code> if the operation succeeded, <code>false</code>
+ * otherwise.
+ *
+ * @exception SecurityException If the <code>SecurityManager</code> does
+ * not allow this operation.
+ *
+ * @since 1.2
+ */
+ public boolean setReadOnly()
+ {
+ // Do a security check before trying to do anything else.
+ checkWrite();
+ return performSetReadOnly();
+ }
+
+ private static native File[] performListRoots();
+
+ /**
+ * This method returns an array of filesystem roots. Some operating systems
+ * have volume oriented filesystem. This method provides a mechanism for
+ * determining which volumes exist. GNU systems use a single hierarchical
+ * filesystem, so will have only one "/" filesystem root.
+ *
+ * @return An array of <code>File</code> objects for each filesystem root
+ * available.
+ *
+ * @since 1.2
+ */
+ public static File[] listRoots()
+ {
+ File[] roots = performListRoots();
+
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ {
+ // Only return roots to which the security manager permits read access.
+ int count = roots.length;
+ for (int i = 0; i < roots.length; i++)
+ {
+ try
+ {
+ s.checkRead (roots[i].path);
+ }
+ catch (SecurityException sx)
+ {
+ roots[i] = null;
+ count--;
+ }
+ }
+ if (count != roots.length)
+ {
+ File[] newRoots = new File[count];
+ int k = 0;
+ for (int i=0; i < roots.length; i++)
+ {
+ if (roots[i] != null)
+ newRoots[k++] = roots[i];
+ }
+ roots = newRoots;
+ }
+ }
+ return roots;
+ }
+
+ /**
+ * This method creates a temporary file in the system temporary directory.
+ * The files created are guaranteed not to currently exist and the same file
+ * name will never be used twice in the same virtual machine instance. The
+ * system temporary directory is determined by examinging the
+ * <code>java.io.tmpdir</code> system property.
+ * <p>
+ * The <code>prefix</code> parameter is a sequence of at least three
+ * characters that are used as the start of the generated filename. The
+ * <code>suffix</code> parameter is a sequence of characters that is used
+ * to terminate the file name. This parameter may be <code>null</code>
+ * and if it is, the suffix defaults to ".tmp".
+ * <p>
+ * If a <code>SecurityManager</code> exists, then its <code>checkWrite</code>
+ * method is used to verify that this operation is permitted.
+ * <p>
+ * This method is identical to calling
+ * <code>createTempFile(prefix, suffix, null)</code>.
+ *
+ * @param prefix The character prefix to use in generating the path name.
+ * @param suffix The character suffix to use in generating the path name.
+ *
+ * @exception IllegalArgumentException If the prefix or suffix are not valid.
+ * @exception SecurityException If there is no permission to perform
+ * this operation
+ * @exception IOException If an error occurs
+ */
+ public static File createTempFile(String prefix, String suffix)
+ throws IOException
+ {
+ return createTempFile(prefix, suffix, null);
+ }
+
+ /**
+ * This method compares the specified <code>File</code> to this one
+ * to test for equality. It does this by comparing the canonical path names
+ * of the files.
+ * <p>
+ * The canonical paths of the files are determined by calling the
+ * <code>getCanonicalPath</code> method on each object.
+ * <p>
+ * This method returns a 0 if the specified <code>Object</code> is equal
+ * to this one, a negative value if it is less than this one
+ * a positive value if it is greater than this one.
+ *
+ * @return An integer as described above
+ *
+ * @since 1.2
+ */
+ public int compareTo(File other)
+ {
+ if (caseSensitive)
+ return path.compareTo (other.path);
+ else
+ return path.compareToIgnoreCase (other.path);
+ }
+
+ /*
+ * This native method actually performs the rename.
+ */
+ private native boolean performRenameTo (File dest);
+
+ /**
+ * This method renames the file represented by this object to the path
+ * of the file represented by the argument <code>File</code>.
+ *
+ * @param dest The <code>File</code> object representing the target name
+ *
+ * @return <code>true</code> if the rename succeeds, <code>false</code>
+ * otherwise.
+ *
+ * @exception SecurityException If write access is not allowed to the
+ * file by the <code>SecurityMananger</code>.
+ */
+ public synchronized boolean renameTo(File dest)
+ {
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ {
+ s.checkWrite (getPath());
+ s.checkWrite (dest.getPath());
+ }
+ return performRenameTo (dest);
+ }
+
+ /*
+ * This method does the actual setting of the modification time.
+ */
+ private native boolean performSetLastModified(long time);
+
+ /**
+ * This method sets the modification time on the file to the specified
+ * value. This is specified as the number of seconds since midnight
+ * on January 1, 1970 GMT.
+ *
+ * @param time The desired modification time.
+ *
+ * @return <code>true</code> if the operation succeeded, <code>false</code>
+ * otherwise.
+ *
+ * @exception IllegalArgumentException If the specified time is negative.
+ * @exception SecurityException If the <code>SecurityManager</code> will
+ * not allow this operation.
+ *
+ * @since 1.2
+ */
+ public boolean setLastModified(long time)
+ {
+ if (time < 0)
+ throw new IllegalArgumentException("Negative modification time: " + time);
+
+ checkWrite();
+ return performSetLastModified(time);
+ }
+
+ private void checkWrite()
+ {
+ // Check the SecurityManager
+ SecurityManager s = System.getSecurityManager();
+
+ if (s != null)
+ s.checkWrite(path);
+ }
+
+ private void checkRead()
+ {
+ // Check the SecurityManager
+ SecurityManager s = System.getSecurityManager();
+
+ if (s != null)
+ s.checkRead(path);
+ }
+
+ private void checkExec()
+ {
+ // Check the SecurityManager
+ SecurityManager s = System.getSecurityManager();
+
+ if (s != null)
+ s.checkExec(path);
+ }
+
+ /**
+ * Calling this method requests that the file represented by this object
+ * be deleted when the virtual machine exits. Note that this request cannot
+ * be cancelled. Also, it will only be carried out if the virtual machine
+ * exits normally.
+ *
+ * @exception SecurityException If deleting of the file is not allowed
+ *
+ * @since 1.2
+ */
+ // FIXME: This should use the ShutdownHook API once we implement that.
+ public void deleteOnExit()
+ {
+ // Check the SecurityManager
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkDelete (getPath());
+
+ DeleteFileHelper.add(this);
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException
+ {
+ oos.defaultWriteObject();
+ oos.writeChar(separatorChar);
+ }
+
+ private void readObject(ObjectInputStream ois)
+ throws ClassNotFoundException, IOException
+ {
+ ois.defaultReadObject();
+
+ // If the file was from an OS with a different dir separator,
+ // fixup the path to use the separator on this OS.
+ char oldSeparatorChar = ois.readChar();
+
+ if (oldSeparatorChar != separatorChar)
+ path = path.replace(oldSeparatorChar, separatorChar);
+ }
+
+} // class File
+
diff --git a/libjava/java/io/FileDescriptor.h b/libjava/java/io/FileDescriptor.h
new file mode 100644
index 000000000..a3863f331
--- /dev/null
+++ b/libjava/java/io/FileDescriptor.h
@@ -0,0 +1,43 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FileDescriptor__
+#define __java_io_FileDescriptor__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace channels
+ {
+ class ByteChannel;
+ }
+ }
+ }
+}
+
+class java::io::FileDescriptor : public ::java::lang::Object
+{
+
+public:
+ FileDescriptor();
+public: // actually package-private
+ FileDescriptor(::java::nio::channels::ByteChannel *);
+public:
+ void sync();
+ jboolean valid();
+ static ::java::io::FileDescriptor * in;
+ static ::java::io::FileDescriptor * out;
+ static ::java::io::FileDescriptor * err;
+public: // actually package-private
+ ::java::nio::channels::ByteChannel * __attribute__((aligned(__alignof__( ::java::lang::Object)))) channel;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FileDescriptor__
diff --git a/libjava/java/io/FileDescriptor.java b/libjava/java/io/FileDescriptor.java
new file mode 100644
index 000000000..d300c9cb6
--- /dev/null
+++ b/libjava/java/io/FileDescriptor.java
@@ -0,0 +1,139 @@
+/* FileDescriptor.java -- Opaque file handle class
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.nio.channels.ByteChannel;
+import java.nio.channels.FileChannel;
+
+/**
+ * This class represents an opaque file handle as a Java class. It should
+ * be used only to pass to other methods that expect an object of this
+ * type. No system specific information can be obtained from this object.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Tom Tromey (tromey@cygnus.com)
+ * @date September 24, 1998
+ */
+public final class FileDescriptor
+{
+ /**
+ * A <code>FileDescriptor</code> representing the system standard input
+ * stream. This will usually be accessed through the
+ * <code>System.in</code>variable.
+ */
+ public static final FileDescriptor in
+ = new FileDescriptor (FileChannelImpl.in);
+
+ /**
+ * A <code>FileDescriptor</code> representing the system standard output
+ * stream. This will usually be accessed through the
+ * <code>System.out</code>variable.
+ */
+ public static final FileDescriptor out
+ = new FileDescriptor (FileChannelImpl.out);
+
+ /**
+ * A <code>FileDescriptor</code> representing the system standard error
+ * stream. This will usually be accessed through the
+ * <code>System.err</code>variable.
+ */
+ public static final FileDescriptor err
+ = new FileDescriptor (FileChannelImpl.err);
+
+ final ByteChannel channel;
+
+ /**
+ * This method is used to initialize an invalid FileDescriptor object.
+ */
+ public FileDescriptor()
+ {
+ channel = null;
+ }
+
+ /**
+ * This method is used to initialize a FileDescriptor object.
+ */
+ FileDescriptor(ByteChannel channel)
+ {
+ this.channel = channel;
+ }
+
+
+ /**
+ * This method forces all data that has not yet been physically written to
+ * the underlying storage medium associated with this
+ * <code>FileDescriptor</code>
+ * to be written out. This method will not return until all data has
+ * been fully written to the underlying device. If the device does not
+ * support this functionality or if an error occurs, then an exception
+ * will be thrown.
+ */
+ public void sync () throws SyncFailedException
+ {
+ if (channel instanceof FileChannel)
+ {
+ try
+ {
+ ((FileChannel) channel).force(true);
+ }
+ catch (IOException ex)
+ {
+ if (ex instanceof SyncFailedException)
+ throw (SyncFailedException) ex;
+ else
+ throw new SyncFailedException(ex.toString());
+ }
+ }
+ }
+
+ /**
+ * This methods tests whether or not this object represents a valid open
+ * native file handle.
+ *
+ * @return <code>true</code> if this object represents a valid
+ * native file handle, <code>false</code> otherwise
+ */
+ public boolean valid ()
+ {
+ return channel != null && channel.isOpen();
+ }
+}
diff --git a/libjava/java/io/FileFilter.h b/libjava/java/io/FileFilter.h
new file mode 100644
index 000000000..e90e43795
--- /dev/null
+++ b/libjava/java/io/FileFilter.h
@@ -0,0 +1,19 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FileFilter__
+#define __java_io_FileFilter__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::FileFilter : public ::java::lang::Object
+{
+
+public:
+ virtual jboolean accept(::java::io::File *) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_FileFilter__
diff --git a/libjava/java/io/FileInputStream.h b/libjava/java/io/FileInputStream.h
new file mode 100644
index 000000000..01efe5620
--- /dev/null
+++ b/libjava/java/io/FileInputStream.h
@@ -0,0 +1,67 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FileInputStream__
+#define __java_io_FileInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace nio
+ {
+ namespace channels
+ {
+ class FileChannelImpl;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace nio
+ {
+ namespace channels
+ {
+ class FileChannel;
+ }
+ }
+ }
+}
+
+class java::io::FileInputStream : public ::java::io::InputStream
+{
+
+public:
+ FileInputStream(::java::lang::String *);
+ FileInputStream(::java::io::File *);
+ FileInputStream(::java::io::FileDescriptor *);
+public: // actually package-private
+ FileInputStream(::gnu::java::nio::channels::FileChannelImpl *);
+public:
+ virtual jint available();
+ virtual void close();
+public: // actually protected
+ virtual void finalize();
+public:
+ virtual ::java::io::FileDescriptor * getFD();
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual jlong skip(jlong);
+ virtual ::java::nio::channels::FileChannel * getChannel();
+private:
+ ::java::io::FileDescriptor * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) fd;
+ ::gnu::java::nio::channels::FileChannelImpl * ch;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FileInputStream__
diff --git a/libjava/java/io/FileInputStream.java b/libjava/java/io/FileInputStream.java
new file mode 100644
index 000000000..8ca38b02f
--- /dev/null
+++ b/libjava/java/io/FileInputStream.java
@@ -0,0 +1,309 @@
+/* FileInputStream.java -- An input stream that reads from disk files.
+ Copyright (C) 1998, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.nio.channels.FileChannel;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * This class is a stream that reads its bytes from a file.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Warren Levy (warrenl@cygnus.com)
+ */
+public class FileInputStream extends InputStream
+{
+ /**
+ * This is the native file handle for the file this stream is reading from
+ */
+ private FileDescriptor fd;
+
+ private FileChannelImpl ch;
+
+ /**
+ * This method initializes a <code>FileInputStream</code> to read from the
+ * specified named file. A security check is first made to determine
+ * whether or not access to this file is allowed. This is done by
+ * calling the <code>checkRead()</code> method of the
+ * <code>SecurityManager</code>
+ * (if one exists) with the name of this file. An exception is thrown
+ * if reading is not allowed. If the file does not exist, an exception
+ * is also thrown.
+ *
+ * @param name The name of the file this stream should read from
+ *
+ * @exception SecurityException If read access to the file is not allowed
+ * @exception FileNotFoundException If the file does not exist
+ * or if it is a directory
+ */
+ public FileInputStream(String name) throws FileNotFoundException
+ {
+ this(new File(name));
+ }
+
+ /**
+ * This method initializes a <code>FileInputStream</code> to read from the
+ * specified <code>File</code> object. A security check is first
+ * made to determine
+ * whether or not access to this file is allowed. This is done by
+ * calling the <code>checkRead()</code> method of the
+ * <code>SecurityManager</code>
+ * (if one exists) with the name of this file. An exception is thrown
+ * if reading is not allowed. If the file does not exist, an exception
+ * is also thrown.
+ *
+ * @param file The <code>File</code> object this stream should read from
+ *
+ * @exception SecurityException If read access to the file is not allowed
+ * @exception FileNotFoundException If the file does not exist
+ * or if it is a directory.
+ */
+ public FileInputStream(File file) throws FileNotFoundException
+ {
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkRead(file.getPath());
+
+ ch = FileChannelImpl.create(file, FileChannelImpl.READ);
+ }
+
+ /**
+ * This method initializes a <code>FileInputStream</code> to read from the
+ * specified <code>FileDescriptor</code> object. A security
+ * check is first made to
+ * determine whether or not access to this file is allowed. This is done by
+ * calling the <code>checkRead()</code> method of the
+ * <code>SecurityManager</code>
+ * (if one exists) with the specified <code>FileDescriptor</code>
+ * An exception is
+ * thrown if reading is not allowed.
+ *
+ * @param fdObj The <code>FileDescriptor</code> object this stream
+ * should read from
+ *
+ * @exception SecurityException If read access to the file is not allowed
+ */
+ public FileInputStream(FileDescriptor fdObj)
+ {
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkRead(fdObj);
+
+ fd = fdObj;
+ ch = (FileChannelImpl) fdObj.channel;
+ }
+
+ FileInputStream(FileChannelImpl ch)
+ {
+ this.ch = ch;
+ }
+
+ /**
+ * This method returns the number of bytes that can be read from this
+ * stream before a read can block. A return of 0 indicates that blocking
+ * might (or might not) occur on the very next read attempt.
+ * <p>
+ * This method returns the number of unread bytes remaining in the file if
+ * the descriptor being read from is an actual file. If this method is
+ * reading from a ''special'' file such a the standard input, this method
+ * will return the appropriate value for the stream being read.
+ * <p>
+ * Be aware that reads on plain files that do not reside locally might
+ * possibly block even if this method says they should not. For example,
+ * a remote server might crash, preventing an NFS mounted file from being
+ * read.
+ *
+ * @return The number of bytes that can be read before blocking could occur
+ *
+ * @exception IOException If an error occurs
+ */
+ public int available() throws IOException
+ {
+ return ch.available();
+ }
+
+ /**
+ * This method closes the stream. Any futher attempts to read from the
+ * stream will likely generate an IOException since the underlying file
+ * will be closed.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public void close() throws IOException
+ {
+ ch.close();
+ }
+
+ protected void finalize() throws IOException
+ {
+ // We don't actually need this, but we include it because it is
+ // mentioned in the JCL.
+ }
+
+ /**
+ * This method returns a <code>FileDescriptor</code> object representing the
+ * underlying native file handle of the file this stream is reading
+ * from
+ *
+ * @return A <code>FileDescriptor</code> for this stream
+ *
+ * @exception IOException If an error occurs
+ */
+ public final FileDescriptor getFD() throws IOException
+ {
+ synchronized (this)
+ {
+ if (fd == null)
+ fd = new FileDescriptor (ch);
+ return fd;
+ }
+ }
+
+ /**
+ * This method reads an unsigned byte from the input stream and returns it
+ * as an int in the range of 0-255. This method also will return -1 if
+ * the end of the stream has been reached.
+ * <p>
+ * This method will block until the byte can be read.
+ *
+ * @return The byte read or -1 if end of stream
+ *
+ * @exception IOException If an error occurs
+ */
+ public int read() throws IOException
+ {
+ return ch.read();
+ }
+
+ /**
+ * This method reads bytes from a stream and stores them into a caller
+ * supplied buffer. This method attempts to completely fill the buffer,
+ * but can return before doing so. The actual number of bytes read is
+ * returned as an int. A -1 is returned to indicate the end of the stream.
+ * <p>
+ * This method will block until some data can be read.
+ * <p>
+ * This method operates by calling an overloaded read method like so:
+ * <code>read(buf, 0, buf.length)</code>
+ *
+ * @param buf The buffer into which the bytes read will be stored.
+ *
+ * @return The number of bytes read or -1 if end of stream.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public int read(byte[] buf) throws IOException
+ {
+ return read(buf, 0, buf.length);
+ }
+
+ /**
+ * This method read bytes from a stream and stores them into a caller
+ * supplied buffer. It starts storing the data at index
+ * <code>offset</code> into
+ * the buffer and attempts to read <code>len</code> bytes. This method can
+ * return before reading the number of bytes requested. The actual number
+ * of bytes read is returned as an int. A -1 is returned to indicate the
+ * end of the stream.
+ * <p>
+ * This method will block until some data can be read.
+ *
+ * @param buf The array into which the bytes read should be stored
+ * @param offset The offset into the array to start storing bytes
+ * @param len The requested number of bytes to read
+ *
+ * @return The actual number of bytes read, or -1 if end of stream.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public int read(byte[] buf, int offset, int len) throws IOException
+ {
+ if (offset < 0
+ || len < 0
+ || offset + len > buf.length)
+ throw new ArrayIndexOutOfBoundsException();
+
+ return ch.read(buf, offset, len);
+ }
+
+ /**
+ * This method skips the specified number of bytes in the stream. It
+ * returns the actual number of bytes skipped, which may be less than the
+ * requested amount.
+ * <p>
+ * @param numBytes The requested number of bytes to skip
+ *
+ * @return The actual number of bytes skipped.
+ *
+ * @exception IOException If an error occurs
+ */
+ public synchronized long skip (long numBytes) throws IOException
+ {
+ if (numBytes < 0)
+ throw new IllegalArgumentException ("Can't skip negative bytes: " +
+ numBytes);
+
+ if (numBytes == 0)
+ return 0;
+
+ long oldPos = ch.position ();
+ ch.position(oldPos + numBytes);
+ return ch.position() - oldPos;
+ }
+
+ /**
+ * This method creates a java.nio.channels.FileChannel.
+ * Nio does not allow one to create a file channel directly.
+ * A file channel must be created by first creating an instance of
+ * Input/Output/RandomAccessFile and invoking the getChannel() method on it.
+ */
+ public synchronized FileChannel getChannel ()
+ {
+ return ch;
+ }
+
+} // class FileInputStream
+
diff --git a/libjava/java/io/FileNotFoundException.h b/libjava/java/io/FileNotFoundException.h
new file mode 100644
index 000000000..794160dd5
--- /dev/null
+++ b/libjava/java/io/FileNotFoundException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FileNotFoundException__
+#define __java_io_FileNotFoundException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+
+class java::io::FileNotFoundException : public ::java::io::IOException
+{
+
+public:
+ FileNotFoundException();
+ FileNotFoundException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = -897856973823710492LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FileNotFoundException__
diff --git a/libjava/java/io/FileOutputStream.h b/libjava/java/io/FileOutputStream.h
new file mode 100644
index 000000000..b2bf0d942
--- /dev/null
+++ b/libjava/java/io/FileOutputStream.h
@@ -0,0 +1,66 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FileOutputStream__
+#define __java_io_FileOutputStream__
+
+#pragma interface
+
+#include <java/io/OutputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace nio
+ {
+ namespace channels
+ {
+ class FileChannelImpl;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace nio
+ {
+ namespace channels
+ {
+ class FileChannel;
+ }
+ }
+ }
+}
+
+class java::io::FileOutputStream : public ::java::io::OutputStream
+{
+
+public:
+ FileOutputStream(::java::lang::String *, jboolean);
+ FileOutputStream(::java::lang::String *);
+ FileOutputStream(::java::io::File *);
+ FileOutputStream(::java::io::File *, jboolean);
+ FileOutputStream(::java::io::FileDescriptor *);
+public: // actually package-private
+ FileOutputStream(::gnu::java::nio::channels::FileChannelImpl *);
+public: // actually protected
+ virtual void finalize();
+public:
+ virtual ::java::io::FileDescriptor * getFD();
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual void close();
+ virtual ::java::nio::channels::FileChannel * getChannel();
+private:
+ ::java::io::FileDescriptor * __attribute__((aligned(__alignof__( ::java::io::OutputStream)))) fd;
+ ::gnu::java::nio::channels::FileChannelImpl * ch;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FileOutputStream__
diff --git a/libjava/java/io/FileOutputStream.java b/libjava/java/io/FileOutputStream.java
new file mode 100644
index 000000000..10ea6b536
--- /dev/null
+++ b/libjava/java/io/FileOutputStream.java
@@ -0,0 +1,296 @@
+/* FileOutputStream.java -- Writes to a file on disk.
+ Copyright (C) 1998, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.nio.channels.FileChannel;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * Status: Complete to version 1.1.
+ */
+
+/**
+ * This classes allows a stream of data to be written to a disk file or
+ * any open <code>FileDescriptor</code>.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Tom Tromey (tromey@cygnus.com)
+ */
+public class FileOutputStream extends OutputStream
+{
+ private FileDescriptor fd;
+
+ private FileChannelImpl ch;
+
+ /**
+ * This method initializes a <code>FileOutputStream</code> object to write
+ * to the named file. The file is created if it does not exist, and
+ * the bytes written are written starting at the beginning of the file if
+ * the <code>append</code> argument is <code>false</code> or at the end
+ * of the file if the <code>append</code> argument is true.
+ * <p>
+ * Before opening a file, a security check is performed by calling the
+ * <code>checkWrite</code> method of the <code>SecurityManager</code> (if
+ * one exists) with the name of the file to be opened. An exception is
+ * thrown if writing is not allowed.
+ *
+ * @param path The name of the file this stream should write to
+ * @param append <code>true</code> to append bytes to the end of the file,
+ * or <code>false</code> to write bytes to the beginning
+ *
+ * @exception SecurityException If write access to the file is not allowed
+ * @exception FileNotFoundException If a non-security error occurs
+ */
+ public FileOutputStream (String path, boolean append)
+ throws SecurityException, FileNotFoundException
+ {
+ this (new File(path), append);
+ }
+
+ /**
+ * This method initializes a <code>FileOutputStream</code> object to write
+ * to the named file. The file is created if it does not exist, and
+ * the bytes written are written starting at the beginning of the file.
+ * <p>
+ * Before opening a file, a security check is performed by calling the
+ * <code>checkWrite</code> method of the <code>SecurityManager</code> (if
+ * one exists) with the name of the file to be opened. An exception is
+ * thrown if writing is not allowed.
+ *
+ * @param path The name of the file this stream should write to
+ *
+ * @exception SecurityException If write access to the file is not allowed
+ * @exception FileNotFoundException If a non-security error occurs
+ */
+ public FileOutputStream (String path)
+ throws SecurityException, FileNotFoundException
+ {
+ this (path, false);
+ }
+
+ /**
+ * This method initializes a <code>FileOutputStream</code> object to write
+ * to the specified <code>File</code> object. The file is created if it
+ * does not exist, and the bytes written are written starting at the
+ * beginning of the file.
+ * <p>
+ * Before opening a file, a security check is performed by calling the
+ * <code>checkWrite</code> method of the <code>SecurityManager</code> (if
+ * one exists) with the name of the file to be opened. An exception is
+ * thrown if writing is not allowed.
+ *
+ * @param file The <code>File</code> object this stream should write to
+ *
+ * @exception SecurityException If write access to the file is not allowed
+ * @exception FileNotFoundException If a non-security error occurs
+ */
+ public FileOutputStream (File file)
+ throws SecurityException, FileNotFoundException
+ {
+ this (file, false);
+ }
+
+ /**
+ * This method initializes a <code>FileOutputStream</code> object to write
+ * to the specified <code>File</code> object. The file is created if it
+ * does not exist, and the bytes written are written starting at the
+ * beginning of the file if the <code>append</code> parameter is
+ * <code>false</code>. Otherwise bytes are written at the end of the
+ * file.
+ * <p>
+ * Before opening a file, a security check is performed by calling the
+ * <code>checkWrite</code> method of the <code>SecurityManager</code> (if
+ * one exists) with the name of the file to be opened. An exception is
+ * thrown if writing is not allowed.
+ *
+ * @param file The <code>File</code> object this stream should write to
+ * @param append <code>true</code> to append bytes to the end of the file,
+ * or <code>false</code> to write bytes to the beginning
+ *
+ * @exception SecurityException If write access to the file is not allowed
+ * @exception FileNotFoundException If a non-security error occurs
+ */
+ public FileOutputStream (File file, boolean append)
+ throws FileNotFoundException
+ {
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkWrite(file.getPath());
+
+ ch = FileChannelImpl.create(file, (append
+ ? FileChannelImpl.WRITE
+ | FileChannelImpl.APPEND
+ : FileChannelImpl.WRITE));
+ }
+
+ /**
+ * This method initializes a <code>FileOutputStream</code> object to write
+ * to the file represented by the specified <code>FileDescriptor</code>
+ * object. This method does not create any underlying disk file or
+ * reposition the file pointer of the given descriptor. It assumes that
+ * this descriptor is ready for writing as is.
+ * <p>
+ * Before opening a file, a security check is performed by calling the
+ * <code>checkWrite</code> method of the <code>SecurityManager</code> (if
+ * one exists) with the specified <code>FileDescriptor</code> as an argument.
+ * An exception is thrown if writing is not allowed.
+ *
+ * @param fdObj The <code>FileDescriptor</code> this stream should write to
+ *
+ * @exception SecurityException If write access to the file is not allowed
+ */
+ public FileOutputStream (FileDescriptor fdObj)
+ throws SecurityException
+ {
+ // Hmm, no other exception but this one to throw, but if the descriptor
+ // isn't valid, we surely don't have "permission" to write to it.
+ if (!fdObj.valid())
+ throw new SecurityException("Invalid FileDescriptor");
+
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkWrite(fdObj);
+
+ fd = fdObj;
+ ch = (FileChannelImpl) fdObj.channel;
+ }
+
+ FileOutputStream(FileChannelImpl ch)
+ {
+ this.ch = ch;
+ }
+
+ protected void finalize () throws IOException
+ {
+ // We don't actually need this, but we include it because it is
+ // mentioned in the JCL.
+ }
+
+ /**
+ * This method returns a <code>FileDescriptor</code> object representing
+ * the file that is currently being written to
+ *
+ * @return A <code>FileDescriptor</code> object for this stream
+ *
+ * @exception IOException If an error occurs
+ */
+ public final FileDescriptor getFD () throws IOException
+ {
+ synchronized (this)
+ {
+ if (fd == null)
+ fd = new FileDescriptor (ch);
+ return fd;
+ }
+ }
+
+ /**
+ * This method writes a single byte of data to the file.
+ *
+ * @param b The byte of data to write, passed as an <code>int</code>
+ *
+ * @exception IOException If an error occurs
+ */
+ public void write (int b) throws IOException
+ {
+ ch.write (b);
+ }
+
+ /**
+ * This method writes all the bytes in the specified array to the
+ * file.
+ *
+ * @param buf The array of bytes to write to the file
+ *
+ * @exception IOException If an error occurs
+ */
+ public void write (byte[] buf)
+ throws IOException
+ {
+ write (buf, 0, buf.length);
+ }
+
+ /**
+ * This method writes <code>len</code> bytes from the byte array
+ * <code>buf</code> to the file starting at index <code>offset</code>.
+ *
+ * @param buf The array of bytes to write to the file
+ * @param offset The offset into the array to start writing bytes from
+ * @param len The number of bytes to write to the file
+ *
+ * @exception IOException If an error occurs
+ */
+ public void write (byte[] buf, int offset, int len)
+ throws IOException
+ {
+ if (offset < 0
+ || len < 0
+ || offset + len > buf.length)
+ throw new ArrayIndexOutOfBoundsException ();
+
+ ch.write (buf, offset, len);
+ }
+
+ /**
+ * This method closes the underlying file. Any further attempts to
+ * write to this stream will likely generate an exception since the
+ * file is closed.
+ *
+ * @exception IOException If an error occurs
+ */
+ public void close () throws IOException
+ {
+ ch.close();
+ }
+
+ /**
+ * This method creates a java.nio.channels.FileChannel.
+ * Nio does not allow one to create a file channel directly.
+ * A file channel must be created by first creating an instance of
+ * Input/Output/RandomAccessFile and invoking the getChannel() method on it.
+ */
+ public synchronized FileChannel getChannel()
+ {
+ return ch;
+ }
+
+} // class FileOutputStream
+
diff --git a/libjava/java/io/FilePermission.h b/libjava/java/io/FilePermission.h
new file mode 100644
index 000000000..bace152f0
--- /dev/null
+++ b/libjava/java/io/FilePermission.h
@@ -0,0 +1,43 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FilePermission__
+#define __java_io_FilePermission__
+
+#pragma interface
+
+#include <java/security/Permission.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace security
+ {
+ class Permission;
+ }
+ }
+}
+
+class java::io::FilePermission : public ::java::security::Permission
+{
+
+ void checkPerms();
+public:
+ FilePermission(::java::lang::String *, ::java::lang::String *);
+ ::java::lang::String * getActions();
+ jint hashCode();
+ jboolean equals(::java::lang::Object *);
+ jboolean implies(::java::security::Permission *);
+private:
+ static const jlong serialVersionUID = 7930732926638008763LL;
+ static ::java::lang::String * ALL_FILES;
+ jboolean __attribute__((aligned(__alignof__( ::java::security::Permission)))) readPerm;
+ jboolean writePerm;
+ jboolean executePerm;
+ jboolean deletePerm;
+ ::java::lang::String * actionsString;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FilePermission__
diff --git a/libjava/java/io/FileReader.h b/libjava/java/io/FileReader.h
new file mode 100644
index 000000000..4d1fba212
--- /dev/null
+++ b/libjava/java/io/FileReader.h
@@ -0,0 +1,21 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FileReader__
+#define __java_io_FileReader__
+
+#pragma interface
+
+#include <java/io/InputStreamReader.h>
+
+class java::io::FileReader : public ::java::io::InputStreamReader
+{
+
+public:
+ FileReader(::java::io::File *);
+ FileReader(::java::io::FileDescriptor *);
+ FileReader(::java::lang::String *);
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FileReader__
diff --git a/libjava/java/io/FileWriter.h b/libjava/java/io/FileWriter.h
new file mode 100644
index 000000000..b75ea008c
--- /dev/null
+++ b/libjava/java/io/FileWriter.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FileWriter__
+#define __java_io_FileWriter__
+
+#pragma interface
+
+#include <java/io/OutputStreamWriter.h>
+
+class java::io::FileWriter : public ::java::io::OutputStreamWriter
+{
+
+public:
+ FileWriter(::java::io::File *);
+ FileWriter(::java::io::File *, jboolean);
+ FileWriter(::java::io::FileDescriptor *);
+ FileWriter(::java::lang::String *);
+ FileWriter(::java::lang::String *, jboolean);
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FileWriter__
diff --git a/libjava/java/io/FilenameFilter.h b/libjava/java/io/FilenameFilter.h
new file mode 100644
index 000000000..2337ed327
--- /dev/null
+++ b/libjava/java/io/FilenameFilter.h
@@ -0,0 +1,19 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FilenameFilter__
+#define __java_io_FilenameFilter__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::FilenameFilter : public ::java::lang::Object
+{
+
+public:
+ virtual jboolean accept(::java::io::File *, ::java::lang::String *) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_FilenameFilter__
diff --git a/libjava/java/io/FilterInputStream.h b/libjava/java/io/FilterInputStream.h
new file mode 100644
index 000000000..1116639c1
--- /dev/null
+++ b/libjava/java/io/FilterInputStream.h
@@ -0,0 +1,34 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FilterInputStream__
+#define __java_io_FilterInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::FilterInputStream : public ::java::io::InputStream
+{
+
+public: // actually protected
+ FilterInputStream(::java::io::InputStream *);
+public:
+ virtual void mark(jint);
+ virtual jboolean markSupported();
+ virtual void reset();
+ virtual jint available();
+ virtual jlong skip(jlong);
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual void close();
+public: // actually protected
+ ::java::io::InputStream * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) in;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FilterInputStream__
diff --git a/libjava/java/io/FilterOutputStream.h b/libjava/java/io/FilterOutputStream.h
new file mode 100644
index 000000000..571b255d6
--- /dev/null
+++ b/libjava/java/io/FilterOutputStream.h
@@ -0,0 +1,29 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FilterOutputStream__
+#define __java_io_FilterOutputStream__
+
+#pragma interface
+
+#include <java/io/OutputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::FilterOutputStream : public ::java::io::OutputStream
+{
+
+public:
+ FilterOutputStream(::java::io::OutputStream *);
+ virtual void close();
+ virtual void flush();
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+public: // actually protected
+ ::java::io::OutputStream * __attribute__((aligned(__alignof__( ::java::io::OutputStream)))) out;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FilterOutputStream__
diff --git a/libjava/java/io/FilterReader.h b/libjava/java/io/FilterReader.h
new file mode 100644
index 000000000..52a1995fe
--- /dev/null
+++ b/libjava/java/io/FilterReader.h
@@ -0,0 +1,33 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FilterReader__
+#define __java_io_FilterReader__
+
+#pragma interface
+
+#include <java/io/Reader.h>
+#include <gcj/array.h>
+
+
+class java::io::FilterReader : public ::java::io::Reader
+{
+
+public: // actually protected
+ FilterReader(::java::io::Reader *);
+public:
+ virtual void mark(jint);
+ virtual jboolean markSupported();
+ virtual void reset();
+ virtual jboolean ready();
+ virtual jlong skip(jlong);
+ virtual jint read();
+ virtual jint read(JArray< jchar > *, jint, jint);
+ virtual void close();
+public: // actually protected
+ ::java::io::Reader * __attribute__((aligned(__alignof__( ::java::io::Reader)))) in;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FilterReader__
diff --git a/libjava/java/io/FilterWriter.h b/libjava/java/io/FilterWriter.h
new file mode 100644
index 000000000..146f01563
--- /dev/null
+++ b/libjava/java/io/FilterWriter.h
@@ -0,0 +1,30 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_FilterWriter__
+#define __java_io_FilterWriter__
+
+#pragma interface
+
+#include <java/io/Writer.h>
+#include <gcj/array.h>
+
+
+class java::io::FilterWriter : public ::java::io::Writer
+{
+
+public: // actually protected
+ FilterWriter(::java::io::Writer *);
+public:
+ virtual void close();
+ virtual void flush();
+ virtual void write(jint);
+ virtual void write(JArray< jchar > *, jint, jint);
+ virtual void write(::java::lang::String *, jint, jint);
+public: // actually protected
+ ::java::io::Writer * __attribute__((aligned(__alignof__( ::java::io::Writer)))) out;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_FilterWriter__
diff --git a/libjava/java/io/Flushable.h b/libjava/java/io/Flushable.h
new file mode 100644
index 000000000..2acd25dec
--- /dev/null
+++ b/libjava/java/io/Flushable.h
@@ -0,0 +1,19 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_Flushable__
+#define __java_io_Flushable__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::Flushable : public ::java::lang::Object
+{
+
+public:
+ virtual void flush() = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_Flushable__
diff --git a/libjava/java/io/IOException.h b/libjava/java/io/IOException.h
new file mode 100644
index 000000000..bdd92e0e4
--- /dev/null
+++ b/libjava/java/io/IOException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_IOException__
+#define __java_io_IOException__
+
+#pragma interface
+
+#include <java/lang/Exception.h>
+
+class java::io::IOException : public ::java::lang::Exception
+{
+
+public:
+ IOException();
+ IOException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = 7818375828146090155LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_IOException__
diff --git a/libjava/java/io/InputStream.h b/libjava/java/io/InputStream.h
new file mode 100644
index 000000000..263af2c81
--- /dev/null
+++ b/libjava/java/io/InputStream.h
@@ -0,0 +1,30 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_InputStream__
+#define __java_io_InputStream__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+
+class java::io::InputStream : public ::java::lang::Object
+{
+
+public:
+ InputStream();
+ virtual jint available();
+ virtual void close();
+ virtual void mark(jint);
+ virtual jboolean markSupported();
+ virtual jint read() = 0;
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual void reset();
+ virtual jlong skip(jlong);
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_InputStream__
diff --git a/libjava/java/io/InputStreamReader.h b/libjava/java/io/InputStreamReader.h
new file mode 100644
index 000000000..46050d5c3
--- /dev/null
+++ b/libjava/java/io/InputStreamReader.h
@@ -0,0 +1,65 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_InputStreamReader__
+#define __java_io_InputStreamReader__
+
+#pragma interface
+
+#include <java/io/Reader.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace gcj
+ {
+ namespace convert
+ {
+ class BytesToUnicode;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class Charset;
+ class CharsetDecoder;
+ }
+ }
+ }
+}
+
+class java::io::InputStreamReader : public ::java::io::Reader
+{
+
+public:
+ InputStreamReader(::java::io::InputStream *);
+ InputStreamReader(::java::io::InputStream *, ::java::lang::String *);
+ InputStreamReader(::java::io::InputStream *, ::java::nio::charset::Charset *);
+ InputStreamReader(::java::io::InputStream *, ::java::nio::charset::CharsetDecoder *);
+private:
+ InputStreamReader(::java::io::InputStream *, ::gnu::gcj::convert::BytesToUnicode *);
+public:
+ virtual void close();
+ virtual ::java::lang::String * getEncoding();
+ virtual jboolean ready();
+ virtual jint read(JArray< jchar > *, jint, jint);
+ virtual jint read();
+private:
+ jint refill(JArray< jchar > *, jint, jint);
+public: // actually package-private
+ ::java::io::BufferedInputStream * __attribute__((aligned(__alignof__( ::java::io::Reader)))) in;
+ JArray< jchar > * work;
+ jint wpos;
+ jint wcount;
+ ::gnu::gcj::convert::BytesToUnicode * converter;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_InputStreamReader__
diff --git a/libjava/java/io/InputStreamReader.java b/libjava/java/io/InputStreamReader.java
new file mode 100644
index 000000000..91568c5cc
--- /dev/null
+++ b/libjava/java/io/InputStreamReader.java
@@ -0,0 +1,332 @@
+/* InputStreamReader.java -- Reader than transforms bytes to chars
+ Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.gcj.convert.*;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+
+/**
+ * This class reads characters from a byte input stream. The characters
+ * read are converted from bytes in the underlying stream by a
+ * decoding layer. The decoding layer transforms bytes to chars according
+ * to an encoding standard. There are many available encodings to choose
+ * from. The desired encoding can either be specified by name, or if no
+ * encoding is selected, the system default encoding will be used. The
+ * system default encoding name is determined from the system property
+ * <code>file.encoding</code>. The only encodings that are guaranteed to
+ * be availalbe are "8859_1" (the Latin-1 character set) and "UTF8".
+ * Unforunately, Java does not provide a mechanism for listing the
+ * ecodings that are supported in a given implementation.
+ * <p>
+ * Here is a list of standard encoding names that may be available:
+ * <p>
+ * <ul>
+ * <li>8859_1 (ISO-8859-1/Latin-1)</li>
+ * <li>8859_2 (ISO-8859-2/Latin-2)</li>
+ * <li>8859_3 (ISO-8859-3/Latin-3)</li>
+ * <li>8859_4 (ISO-8859-4/Latin-4)</li>
+ * <li>8859_5 (ISO-8859-5/Latin-5)</li>
+ * <li>8859_6 (ISO-8859-6/Latin-6)</li>
+ * <li>8859_7 (ISO-8859-7/Latin-7)</li>
+ * <li>8859_8 (ISO-8859-8/Latin-8)</li>
+ * <li>8859_9 (ISO-8859-9/Latin-9)</li>
+ * <li>ASCII (7-bit ASCII)</li>
+ * <li>UTF8 (UCS Transformation Format-8)</li>
+ * <li>More later</li>
+ * </ul>
+ * <p>
+ * It is recommended that applications do not use
+ * <code>InputStreamReader</code>'s
+ * directly. Rather, for efficiency purposes, an object of this class
+ * should be wrapped by a <code>BufferedReader</code>.
+ * <p>
+ * Due to a deficiency the Java class library design, there is no standard
+ * way for an application to install its own byte-character encoding.
+ *
+ * @see BufferedReader
+ * @see InputStream
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Per Bothner (bothner@cygnus.com)
+ * @date April 22, 1998.
+ */
+public class InputStreamReader extends Reader
+{
+ BufferedInputStream in;
+
+ // Buffer of chars read from in and converted but not consumed.
+ char[] work;
+ // Next available character (in work buffer) to read.
+ int wpos;
+ // Last available character (in work buffer) to read.
+ int wcount;
+
+ /*
+ * This is the byte-character decoder class that does the reading and
+ * translation of bytes from the underlying stream.
+ */
+ BytesToUnicode converter;
+
+ /**
+ * This method initializes a new instance of <code>InputStreamReader</code>
+ * to read from the specified stream using the default encoding.
+ *
+ * @param in The <code>InputStream</code> to read from
+ */
+ public InputStreamReader(InputStream in)
+ {
+ this(in, BytesToUnicode.getDefaultDecoder());
+ }
+
+ /**
+ * This method initializes a new instance of <code>InputStreamReader</code>
+ * to read from the specified stream using a caller supplied character
+ * encoding scheme. Note that due to a deficiency in the Java language
+ * design, there is no way to determine which encodings are supported.
+ *
+ * @param in The <code>InputStream</code> to read from
+ * @param encoding_name The name of the encoding scheme to use
+ *
+ * @exception UnsupportedEncodingException If the encoding scheme
+ * requested is not available.
+ */
+ public InputStreamReader(InputStream in, String encoding_name)
+ throws UnsupportedEncodingException
+ {
+ this(in, BytesToUnicode.getDecoder(encoding_name));
+ }
+
+ /**
+ * Creates an InputStreamReader that uses a decoder of the given
+ * charset to decode the bytes in the InputStream into
+ * characters.
+ */
+ public InputStreamReader(InputStream in, Charset charset)
+ {
+ this(in, new BytesToCharsetAdaptor(charset));
+ }
+
+ /**
+ * Creates an InputStreamReader that uses the given charset decoder
+ * to decode the bytes in the InputStream into characters.
+ */
+ public InputStreamReader(InputStream in, CharsetDecoder decoder)
+ {
+ this(in, new BytesToCharsetAdaptor(decoder));
+ }
+
+ private InputStreamReader(InputStream in, BytesToUnicode decoder)
+ {
+ // FIXME: someone could pass in a BufferedInputStream whose buffer
+ // is smaller than the longest encoded character for this
+ // encoding. We will probably go into an infinite loop in this
+ // case. We probably ought to just have our own byte buffering
+ // here.
+ this.in = in instanceof BufferedInputStream
+ ? (BufferedInputStream) in
+ : new BufferedInputStream(in);
+ /* Don't need to call super(in) here as long as the lock gets set. */
+ this.lock = in;
+ converter = decoder;
+ converter.setInput(this.in.buf, 0, 0);
+ }
+
+ /**
+ * This method closes this stream, as well as the underlying
+ * <code>InputStream</code>.
+ *
+ * @exception IOException If an error occurs
+ */
+ public void close() throws IOException
+ {
+ synchronized (lock)
+ {
+ if (in != null)
+ in.close();
+ in = null;
+ work = null;
+ wpos = wcount = 0;
+ }
+ }
+
+ /**
+ * This method returns the name of the encoding that is currently in use
+ * by this object. If the stream has been closed, this method is allowed
+ * to return <code>null</code>.
+ *
+ * @return The current encoding name
+ */
+ public String getEncoding()
+ {
+ return in != null ? converter.getName() : null;
+ }
+
+ /**
+ * This method checks to see if the stream is read to be read. It
+ * will return <code>true</code> if is, or <code>false</code> if it is not.
+ * If the stream is not ready to be read, it could (although is not required
+ * to) block on the next read attempt.
+ *
+ * @return <code>true</code> if the stream is ready to be read,
+ * <code>false</code> otherwise
+ *
+ * @exception IOException If an error occurs
+ */
+ public boolean ready() throws IOException
+ {
+ synchronized (lock)
+ {
+ if (in == null)
+ throw new IOException("Stream closed");
+
+ if (wpos < wcount)
+ return true;
+
+ // According to the spec, an InputStreamReader is ready if its
+ // input buffer is not empty (above), or if bytes are
+ // available on the underlying byte stream.
+ return in.available () > 0;
+ }
+ }
+
+ /**
+ * This method reads up to <code>length</code> characters from the stream into
+ * the specified array starting at index <code>offset</code> into the
+ * array.
+ *
+ * @param buf The character array to recieve the data read
+ * @param offset The offset into the array to start storing characters
+ * @param length The requested number of characters to read.
+ *
+ * @return The actual number of characters read, or -1 if end of stream.
+ *
+ * @exception IOException If an error occurs
+ */
+ public int read (char[] buf, int offset, int length) throws IOException
+ {
+ synchronized (lock)
+ {
+ if (in == null)
+ throw new IOException("Stream closed");
+
+ if (length == 0)
+ return 0;
+
+ int wavail = wcount - wpos;
+ if (wavail <= 0)
+ {
+ // Nothing waiting, so refill their buffer.
+ return refill(buf, offset, length);
+ }
+
+ if (length > wavail)
+ length = wavail;
+ System.arraycopy(work, wpos, buf, offset, length);
+ wpos += length;
+ return length;
+ }
+ }
+
+ /**
+ * This method reads a single character of data from the stream.
+ *
+ * @return The char read, as an int, or -1 if end of stream.
+ *
+ * @exception IOException If an error occurs
+ */
+ public int read() throws IOException
+ {
+ synchronized (lock)
+ {
+ if (in == null)
+ throw new IOException("Stream closed");
+
+ int wavail = wcount - wpos;
+ if (wavail <= 0)
+ {
+ // Nothing waiting, so refill our internal buffer.
+ wpos = wcount = 0;
+ if (work == null)
+ work = new char[100];
+ int count = refill(work, 0, work.length);
+ if (count == -1)
+ return -1;
+ wcount += count;
+ }
+
+ return work[wpos++];
+ }
+ }
+
+ // Read more bytes and convert them into the specified buffer.
+ // Returns the number of converted characters or -1 on EOF.
+ private int refill(char[] buf, int offset, int length) throws IOException
+ {
+ for (;;)
+ {
+ // We have knowledge of the internals of BufferedInputStream
+ // here. Eww.
+ // BufferedInputStream.refill() can only be called when
+ // `pos>=count'.
+ boolean r = in.pos < in.count || in.refill ();
+ if (! r)
+ return -1;
+ converter.setInput(in.buf, in.pos, in.count);
+ int count = converter.read(buf, offset, length);
+
+ // We might have bytes but not have made any progress. In
+ // this case we try to refill. If refilling fails, we assume
+ // we have a malformed character at the end of the stream.
+ if (count == 0 && converter.inpos == in.pos)
+ {
+ in.mark(in.count);
+ if (! in.refill ())
+ throw new CharConversionException ();
+ in.reset();
+ }
+ else
+ {
+ in.skip(converter.inpos - in.pos);
+ if (count > 0)
+ return count;
+ }
+ }
+ }
+}
diff --git a/libjava/java/io/InterruptedIOException.h b/libjava/java/io/InterruptedIOException.h
new file mode 100644
index 000000000..40922cd79
--- /dev/null
+++ b/libjava/java/io/InterruptedIOException.h
@@ -0,0 +1,26 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_InterruptedIOException__
+#define __java_io_InterruptedIOException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+
+class java::io::InterruptedIOException : public ::java::io::IOException
+{
+
+public:
+ InterruptedIOException();
+ InterruptedIOException(::java::lang::String *);
+public: // actually package-private
+ InterruptedIOException(::java::lang::String *, jint);
+private:
+ static const jlong serialVersionUID = 4020568460727500567LL;
+public:
+ jint __attribute__((aligned(__alignof__( ::java::io::IOException)))) bytesTransferred;
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_InterruptedIOException__
diff --git a/libjava/java/io/InvalidClassException.h b/libjava/java/io/InvalidClassException.h
new file mode 100644
index 000000000..6216a9ad9
--- /dev/null
+++ b/libjava/java/io/InvalidClassException.h
@@ -0,0 +1,25 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_InvalidClassException__
+#define __java_io_InvalidClassException__
+
+#pragma interface
+
+#include <java/io/ObjectStreamException.h>
+
+class java::io::InvalidClassException : public ::java::io::ObjectStreamException
+{
+
+public:
+ InvalidClassException(::java::lang::String *);
+ InvalidClassException(::java::lang::String *, ::java::lang::String *);
+ virtual ::java::lang::String * getMessage();
+private:
+ static const jlong serialVersionUID = -4333316296251054416LL;
+public:
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::io::ObjectStreamException)))) classname;
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_InvalidClassException__
diff --git a/libjava/java/io/InvalidObjectException.h b/libjava/java/io/InvalidObjectException.h
new file mode 100644
index 000000000..550dd439d
--- /dev/null
+++ b/libjava/java/io/InvalidObjectException.h
@@ -0,0 +1,22 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_InvalidObjectException__
+#define __java_io_InvalidObjectException__
+
+#pragma interface
+
+#include <java/io/ObjectStreamException.h>
+
+class java::io::InvalidObjectException : public ::java::io::ObjectStreamException
+{
+
+public:
+ InvalidObjectException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = 3233174318281839583LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_InvalidObjectException__
diff --git a/libjava/java/io/LineNumberInputStream.h b/libjava/java/io/LineNumberInputStream.h
new file mode 100644
index 000000000..676893d51
--- /dev/null
+++ b/libjava/java/io/LineNumberInputStream.h
@@ -0,0 +1,34 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_LineNumberInputStream__
+#define __java_io_LineNumberInputStream__
+
+#pragma interface
+
+#include <java/io/FilterInputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::LineNumberInputStream : public ::java::io::FilterInputStream
+{
+
+public:
+ LineNumberInputStream(::java::io::InputStream *);
+ virtual jint available();
+ virtual jint getLineNumber();
+ virtual void mark(jint);
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual void reset();
+ virtual void setLineNumber(jint);
+ virtual jlong skip(jlong);
+private:
+ jint __attribute__((aligned(__alignof__( ::java::io::FilterInputStream)))) lineNumber;
+ jint markLineNumber;
+ jboolean justReadReturnChar;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_LineNumberInputStream__
diff --git a/libjava/java/io/LineNumberReader.h b/libjava/java/io/LineNumberReader.h
new file mode 100644
index 000000000..33564c949
--- /dev/null
+++ b/libjava/java/io/LineNumberReader.h
@@ -0,0 +1,41 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_LineNumberReader__
+#define __java_io_LineNumberReader__
+
+#pragma interface
+
+#include <java/io/BufferedReader.h>
+#include <gcj/array.h>
+
+
+class java::io::LineNumberReader : public ::java::io::BufferedReader
+{
+
+public:
+ LineNumberReader(::java::io::Reader *);
+ LineNumberReader(::java::io::Reader *, jint);
+ virtual jint getLineNumber();
+ virtual void setLineNumber(jint);
+ virtual void mark(jint);
+ virtual void reset();
+private:
+ jint fill();
+public:
+ virtual jint read();
+ virtual jint read(JArray< jchar > *, jint, jint);
+private:
+ void skipRedundantLF();
+public:
+ virtual ::java::lang::String * readLine();
+ virtual jlong skip(jlong);
+private:
+ jint __attribute__((aligned(__alignof__( ::java::io::BufferedReader)))) lineNumber;
+ jboolean matchedNewLine;
+ jint savedLineNumber;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_LineNumberReader__
diff --git a/libjava/java/io/NotActiveException.h b/libjava/java/io/NotActiveException.h
new file mode 100644
index 000000000..9020e4e03
--- /dev/null
+++ b/libjava/java/io/NotActiveException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_NotActiveException__
+#define __java_io_NotActiveException__
+
+#pragma interface
+
+#include <java/io/ObjectStreamException.h>
+
+class java::io::NotActiveException : public ::java::io::ObjectStreamException
+{
+
+public:
+ NotActiveException();
+ NotActiveException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = -3893467273049808895LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_NotActiveException__
diff --git a/libjava/java/io/NotSerializableException.h b/libjava/java/io/NotSerializableException.h
new file mode 100644
index 000000000..55699b406
--- /dev/null
+++ b/libjava/java/io/NotSerializableException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_NotSerializableException__
+#define __java_io_NotSerializableException__
+
+#pragma interface
+
+#include <java/io/ObjectStreamException.h>
+
+class java::io::NotSerializableException : public ::java::io::ObjectStreamException
+{
+
+public:
+ NotSerializableException();
+ NotSerializableException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = 2906642554793891381LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_NotSerializableException__
diff --git a/libjava/java/io/ObjectInput.h b/libjava/java/io/ObjectInput.h
new file mode 100644
index 000000000..7cfac2060
--- /dev/null
+++ b/libjava/java/io/ObjectInput.h
@@ -0,0 +1,42 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectInput__
+#define __java_io_ObjectInput__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+
+class java::io::ObjectInput : public ::java::lang::Object
+{
+
+public:
+ virtual jint available() = 0;
+ virtual jint read() = 0;
+ virtual jint read(JArray< jbyte > *) = 0;
+ virtual jint read(JArray< jbyte > *, jint, jint) = 0;
+ virtual ::java::lang::Object * readObject() = 0;
+ virtual jlong skip(jlong) = 0;
+ virtual void close() = 0;
+ virtual jboolean readBoolean() = 0;
+ virtual jbyte readByte() = 0;
+ virtual jint readUnsignedByte() = 0;
+ virtual jchar readChar() = 0;
+ virtual jshort readShort() = 0;
+ virtual jint readUnsignedShort() = 0;
+ virtual jint readInt() = 0;
+ virtual jlong readLong() = 0;
+ virtual jfloat readFloat() = 0;
+ virtual jdouble readDouble() = 0;
+ virtual ::java::lang::String * readLine() = 0;
+ virtual ::java::lang::String * readUTF() = 0;
+ virtual void readFully(JArray< jbyte > *) = 0;
+ virtual void readFully(JArray< jbyte > *, jint, jint) = 0;
+ virtual jint skipBytes(jint) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_ObjectInput__
diff --git a/libjava/java/io/ObjectInputStream$1.h b/libjava/java/io/ObjectInputStream$1.h
new file mode 100644
index 000000000..364cab09c
--- /dev/null
+++ b/libjava/java/io/ObjectInputStream$1.h
@@ -0,0 +1,26 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectInputStream$1__
+#define __java_io_ObjectInputStream$1__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectInputStream$1 : public ::java::lang::Object
+{
+
+public: // actually package-private
+ ObjectInputStream$1(::java::io::ObjectInputStream *, ::java::lang::Class *);
+public:
+ virtual ::java::lang::Object * run();
+public: // actually package-private
+ ::java::io::ObjectInputStream * __attribute__((aligned(__alignof__( ::java::lang::Object)))) this$0;
+private:
+ ::java::lang::Class * val$local_constructor_class;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectInputStream$1__
diff --git a/libjava/java/io/ObjectInputStream$2.h b/libjava/java/io/ObjectInputStream$2.h
new file mode 100644
index 000000000..22124d2c3
--- /dev/null
+++ b/libjava/java/io/ObjectInputStream$2.h
@@ -0,0 +1,42 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectInputStream$2__
+#define __java_io_ObjectInputStream$2__
+
+#pragma interface
+
+#include <java/io/ObjectInputStream$GetField.h>
+#include <gcj/array.h>
+
+
+class java::io::ObjectInputStream$2 : public ::java::io::ObjectInputStream$GetField
+{
+
+public: // actually package-private
+ ObjectInputStream$2(::java::io::ObjectInputStream *, ::java::io::ObjectStreamClass *, JArray< jbyte > *, JArray< ::java::lang::Object * > *);
+public:
+ virtual ::java::io::ObjectStreamClass * getObjectStreamClass();
+ virtual jboolean defaulted(::java::lang::String *);
+ virtual jboolean get(::java::lang::String *, jboolean);
+ virtual jchar get(::java::lang::String *, jchar);
+ virtual jbyte get(::java::lang::String *, jbyte);
+ virtual jshort get(::java::lang::String *, jshort);
+ virtual jint get(::java::lang::String *, jint);
+ virtual jlong get(::java::lang::String *, jlong);
+ virtual jfloat get(::java::lang::String *, jfloat);
+ virtual jdouble get(::java::lang::String *, jdouble);
+ virtual ::java::lang::Object * get(::java::lang::String *, ::java::lang::Object *);
+private:
+ ::java::io::ObjectStreamField * getField(::java::lang::String *, ::java::lang::Class *);
+public: // actually package-private
+ ::java::io::ObjectInputStream * __attribute__((aligned(__alignof__( ::java::io::ObjectInputStream$GetField)))) this$0;
+private:
+ ::java::io::ObjectStreamClass * val$clazz;
+ JArray< jbyte > * val$prim_field_data;
+ JArray< ::java::lang::Object * > * val$objs;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectInputStream$2__
diff --git a/libjava/java/io/ObjectInputStream$GetField.h b/libjava/java/io/ObjectInputStream$GetField.h
new file mode 100644
index 000000000..d61509c4a
--- /dev/null
+++ b/libjava/java/io/ObjectInputStream$GetField.h
@@ -0,0 +1,30 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectInputStream$GetField__
+#define __java_io_ObjectInputStream$GetField__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectInputStream$GetField : public ::java::lang::Object
+{
+
+public:
+ ObjectInputStream$GetField();
+ virtual ::java::io::ObjectStreamClass * getObjectStreamClass() = 0;
+ virtual jboolean defaulted(::java::lang::String *) = 0;
+ virtual jboolean get(::java::lang::String *, jboolean) = 0;
+ virtual jchar get(::java::lang::String *, jchar) = 0;
+ virtual jbyte get(::java::lang::String *, jbyte) = 0;
+ virtual jshort get(::java::lang::String *, jshort) = 0;
+ virtual jint get(::java::lang::String *, jint) = 0;
+ virtual jlong get(::java::lang::String *, jlong) = 0;
+ virtual jfloat get(::java::lang::String *, jfloat) = 0;
+ virtual jdouble get(::java::lang::String *, jdouble) = 0;
+ virtual ::java::lang::Object * get(::java::lang::String *, ::java::lang::Object *) = 0;
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectInputStream$GetField__
diff --git a/libjava/java/io/ObjectInputStream$ValidatorAndPriority.h b/libjava/java/io/ObjectInputStream$ValidatorAndPriority.h
new file mode 100644
index 000000000..02e6ae623
--- /dev/null
+++ b/libjava/java/io/ObjectInputStream$ValidatorAndPriority.h
@@ -0,0 +1,25 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectInputStream$ValidatorAndPriority__
+#define __java_io_ObjectInputStream$ValidatorAndPriority__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectInputStream$ValidatorAndPriority : public ::java::lang::Object
+{
+
+public: // actually package-private
+ ObjectInputStream$ValidatorAndPriority(::java::io::ObjectInputValidation *, jint);
+public:
+ jint compareTo(::java::lang::Object *);
+public: // actually package-private
+ jint __attribute__((aligned(__alignof__( ::java::lang::Object)))) priority;
+ ::java::io::ObjectInputValidation * validator;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectInputStream$ValidatorAndPriority__
diff --git a/libjava/java/io/ObjectInputStream.h b/libjava/java/io/ObjectInputStream.h
new file mode 100644
index 000000000..ab7c47d2b
--- /dev/null
+++ b/libjava/java/io/ObjectInputStream.h
@@ -0,0 +1,106 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectInputStream__
+#define __java_io_ObjectInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::ObjectInputStream : public ::java::io::InputStream
+{
+
+public:
+ ObjectInputStream(::java::io::InputStream *);
+ virtual ::java::lang::Object * readObject();
+ virtual ::java::lang::Object * readUnshared();
+private:
+ ::java::lang::Object * readObject(jboolean);
+ ::java::lang::Object * parseContent(jbyte, jboolean);
+ void checkTypeConsistency(::java::lang::String *, JArray< ::java::io::ObjectStreamField * > *, JArray< ::java::io::ObjectStreamField * > *);
+public: // actually protected
+ virtual ::java::io::ObjectStreamClass * readClassDescriptor();
+public:
+ virtual void defaultReadObject();
+ virtual void registerValidation(::java::io::ObjectInputValidation *, jint);
+public: // actually protected
+ virtual ::java::lang::Class * resolveClass(::java::io::ObjectStreamClass *);
+private:
+ ::java::lang::ClassLoader * currentLoader();
+ ::java::io::ObjectStreamClass * lookupClass(::java::lang::Class *);
+ JArray< ::java::io::ObjectStreamClass * > * hierarchy(::java::lang::Class *);
+public: // actually protected
+ virtual ::java::lang::Object * resolveObject(::java::lang::Object *);
+ virtual ::java::lang::Class * resolveProxyClass(JArray< ::java::lang::String * > *);
+ virtual jboolean enableResolveObject(jboolean);
+ virtual void readStreamHeader();
+public:
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual jint available();
+ virtual void close();
+ virtual jboolean readBoolean();
+ virtual jbyte readByte();
+ virtual jint readUnsignedByte();
+ virtual jshort readShort();
+ virtual jint readUnsignedShort();
+ virtual jchar readChar();
+ virtual jint readInt();
+ virtual jlong readLong();
+ virtual jfloat readFloat();
+ virtual jdouble readDouble();
+ virtual void readFully(JArray< jbyte > *);
+ virtual void readFully(JArray< jbyte > *, jint, jint);
+ virtual jint skipBytes(jint);
+ virtual ::java::lang::String * readLine();
+ virtual ::java::lang::String * readUTF();
+ virtual ::java::io::ObjectInputStream$GetField * readFields();
+public: // actually protected
+ ObjectInputStream();
+ virtual ::java::lang::Object * readObjectOverride();
+private:
+ jint assignNewHandle(::java::lang::Object *, jboolean);
+ void rememberHandle(::java::lang::Object *, jboolean, jint);
+ ::java::lang::Object * lookupHandle(jint);
+ ::java::lang::Object * processResolution(::java::io::ObjectStreamClass *, ::java::lang::Object *, jint, jboolean);
+ void clearHandles();
+ void readNextBlock();
+ void readNextBlock(jbyte);
+ void readArrayElements(::java::lang::Object *, ::java::lang::Class *);
+ void readFields(::java::lang::Object *, ::java::io::ObjectStreamClass *);
+ jboolean setBlockDataMode(jboolean);
+ ::java::lang::Object * newObject(::java::lang::Class *, ::java::lang::reflect::Constructor *);
+ void invokeValidators();
+ void callReadMethod(::java::lang::reflect::Method *, ::java::lang::Class *, ::java::lang::Object *);
+ void dumpElement(::java::lang::String *);
+ void dumpElementln(::java::lang::String *);
+ void dumpElementln(::java::lang::String *, ::java::lang::Object *);
+ static const jint BUFFER_SIZE = 1024;
+ ::java::io::DataInputStream * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) realInputStream;
+ ::java::io::DataInputStream * dataInputStream;
+ ::java::io::DataInputStream * blockDataInput;
+ jint blockDataPosition;
+ jint blockDataBytes;
+ JArray< jbyte > * blockData;
+ jboolean useSubclassMethod;
+ jint nextOID;
+ jboolean resolveEnabled;
+ ::java::util::Map * handles;
+ ::java::lang::Object * currentObject;
+ ::java::io::ObjectStreamClass * currentObjectStreamClass;
+ ::java::util::TreeSet * currentObjectValidators;
+ jboolean readDataFromBlock;
+ jboolean fieldsAlreadyRead;
+ ::java::util::Hashtable * classLookupTable;
+ ::java::io::ObjectInputStream$GetField * prereadFields;
+ static jboolean dump;
+ jint depth;
+ static const jboolean DEBUG = 0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectInputStream__
diff --git a/libjava/java/io/ObjectInputValidation.h b/libjava/java/io/ObjectInputValidation.h
new file mode 100644
index 000000000..6b0df7dfc
--- /dev/null
+++ b/libjava/java/io/ObjectInputValidation.h
@@ -0,0 +1,19 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectInputValidation__
+#define __java_io_ObjectInputValidation__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectInputValidation : public ::java::lang::Object
+{
+
+public:
+ virtual void validateObject() = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_ObjectInputValidation__
diff --git a/libjava/java/io/ObjectOutput.h b/libjava/java/io/ObjectOutput.h
new file mode 100644
index 000000000..ec45c0193
--- /dev/null
+++ b/libjava/java/io/ObjectOutput.h
@@ -0,0 +1,37 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectOutput__
+#define __java_io_ObjectOutput__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+
+class java::io::ObjectOutput : public ::java::lang::Object
+{
+
+public:
+ virtual void write(jint) = 0;
+ virtual void write(JArray< jbyte > *) = 0;
+ virtual void write(JArray< jbyte > *, jint, jint) = 0;
+ virtual void writeObject(::java::lang::Object *) = 0;
+ virtual void flush() = 0;
+ virtual void close() = 0;
+ virtual void writeBoolean(jboolean) = 0;
+ virtual void writeByte(jint) = 0;
+ virtual void writeChar(jint) = 0;
+ virtual void writeShort(jint) = 0;
+ virtual void writeInt(jint) = 0;
+ virtual void writeLong(jlong) = 0;
+ virtual void writeFloat(jfloat) = 0;
+ virtual void writeDouble(jdouble) = 0;
+ virtual void writeBytes(::java::lang::String *) = 0;
+ virtual void writeChars(::java::lang::String *) = 0;
+ virtual void writeUTF(::java::lang::String *) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_ObjectOutput__
diff --git a/libjava/java/io/ObjectOutputStream$1.h b/libjava/java/io/ObjectOutputStream$1.h
new file mode 100644
index 000000000..6c17fe723
--- /dev/null
+++ b/libjava/java/io/ObjectOutputStream$1.h
@@ -0,0 +1,41 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectOutputStream$1__
+#define __java_io_ObjectOutputStream$1__
+
+#pragma interface
+
+#include <java/io/ObjectOutputStream$PutField.h>
+#include <gcj/array.h>
+
+
+class java::io::ObjectOutputStream$1 : public ::java::io::ObjectOutputStream$PutField
+{
+
+public: // actually package-private
+ ObjectOutputStream$1(::java::io::ObjectOutputStream *);
+private:
+ ::java::io::ObjectStreamField * getField(::java::lang::String *);
+public:
+ virtual void put(::java::lang::String *, jboolean);
+ virtual void put(::java::lang::String *, jbyte);
+ virtual void put(::java::lang::String *, jchar);
+ virtual void put(::java::lang::String *, jdouble);
+ virtual void put(::java::lang::String *, jfloat);
+ virtual void put(::java::lang::String *, jint);
+ virtual void put(::java::lang::String *, jlong);
+ virtual void put(::java::lang::String *, jshort);
+ virtual void put(::java::lang::String *, ::java::lang::Object *);
+ virtual void write(::java::io::ObjectOutput *);
+private:
+ void checkType(::java::io::ObjectStreamField *, jchar);
+ JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::io::ObjectOutputStream$PutField)))) prim_field_data;
+ JArray< ::java::lang::Object * > * objs;
+public: // actually package-private
+ ::java::io::ObjectOutputStream * this$0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectOutputStream$1__
diff --git a/libjava/java/io/ObjectOutputStream$PutField.h b/libjava/java/io/ObjectOutputStream$PutField.h
new file mode 100644
index 000000000..790bb0e09
--- /dev/null
+++ b/libjava/java/io/ObjectOutputStream$PutField.h
@@ -0,0 +1,29 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectOutputStream$PutField__
+#define __java_io_ObjectOutputStream$PutField__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectOutputStream$PutField : public ::java::lang::Object
+{
+
+public:
+ ObjectOutputStream$PutField();
+ virtual void put(::java::lang::String *, jboolean) = 0;
+ virtual void put(::java::lang::String *, jbyte) = 0;
+ virtual void put(::java::lang::String *, jchar) = 0;
+ virtual void put(::java::lang::String *, jdouble) = 0;
+ virtual void put(::java::lang::String *, jfloat) = 0;
+ virtual void put(::java::lang::String *, jint) = 0;
+ virtual void put(::java::lang::String *, jlong) = 0;
+ virtual void put(::java::lang::String *, jshort) = 0;
+ virtual void put(::java::lang::String *, ::java::lang::Object *) = 0;
+ virtual void write(::java::io::ObjectOutput *) = 0;
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectOutputStream$PutField__
diff --git a/libjava/java/io/ObjectOutputStream.h b/libjava/java/io/ObjectOutputStream.h
new file mode 100644
index 000000000..fe6f88f11
--- /dev/null
+++ b/libjava/java/io/ObjectOutputStream.h
@@ -0,0 +1,126 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectOutputStream__
+#define __java_io_ObjectOutputStream__
+
+#pragma interface
+
+#include <java/io/OutputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace io
+ {
+ class ObjectIdentityMap2Int;
+ }
+ namespace security
+ {
+ namespace action
+ {
+ class SetAccessibleAction;
+ }
+ }
+ }
+ }
+}
+
+class java::io::ObjectOutputStream : public ::java::io::OutputStream
+{
+
+public:
+ ObjectOutputStream(::java::io::OutputStream *);
+ virtual void writeObject(::java::lang::Object *);
+ virtual void writeUnshared(::java::lang::Object *);
+private:
+ void writeObject(::java::lang::Object *, jboolean);
+public: // actually protected
+ virtual void writeClassDescriptor(::java::io::ObjectStreamClass *);
+public:
+ virtual void defaultWriteObject();
+private:
+ void markFieldsWritten();
+public:
+ virtual void reset();
+private:
+ void reset(jboolean);
+public:
+ virtual void useProtocolVersion(jint);
+public: // actually protected
+ virtual void annotateClass(::java::lang::Class *);
+ virtual void annotateProxyClass(::java::lang::Class *);
+ virtual ::java::lang::Object * replaceObject(::java::lang::Object *);
+ virtual jboolean enableReplaceObject(jboolean);
+ virtual void writeStreamHeader();
+ ObjectOutputStream();
+ virtual void writeObjectOverride(::java::lang::Object *);
+public:
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual void flush();
+public: // actually protected
+ virtual void drain();
+public:
+ virtual void close();
+ virtual void writeBoolean(jboolean);
+ virtual void writeByte(jint);
+ virtual void writeShort(jint);
+ virtual void writeChar(jint);
+ virtual void writeInt(jint);
+ virtual void writeLong(jlong);
+ virtual void writeFloat(jfloat);
+ virtual void writeDouble(jdouble);
+ virtual void writeBytes(::java::lang::String *);
+ virtual void writeChars(::java::lang::String *);
+ virtual void writeUTF(::java::lang::String *);
+ virtual ::java::io::ObjectOutputStream$PutField * putFields();
+ virtual void writeFields();
+private:
+ void writeBlockDataHeader(jint);
+ jint findHandle(::java::lang::Object *);
+ jint assignNewHandle(::java::lang::Object *);
+ void clearHandles();
+ void writeArraySizeAndElements(::java::lang::Object *, ::java::lang::Class *);
+ void writeFields(::java::lang::Object *, ::java::io::ObjectStreamClass *);
+ void writeFields(::java::lang::Object *, JArray< ::java::io::ObjectStreamField * > *);
+public: // actually package-private
+ virtual jboolean setBlockDataMode(jboolean);
+private:
+ void callWriteMethod(::java::lang::Object *, ::java::io::ObjectStreamClass *);
+ void dumpElementln(::java::lang::String *, ::java::lang::Object *);
+ void dumpElementln(::java::lang::String *);
+ static const jint BUFFER_SIZE = 1024;
+ static jint defaultProtocolVersion;
+ ::java::io::DataOutputStream * __attribute__((aligned(__alignof__( ::java::io::OutputStream)))) dataOutput;
+ jboolean writeDataAsBlocks;
+ ::java::io::DataOutputStream * realOutput;
+ ::java::io::DataOutputStream * blockDataOutput;
+ JArray< jbyte > * blockData;
+ jint blockDataCount;
+ ::java::lang::Object * currentObject;
+public: // actually package-private
+ ::java::io::ObjectStreamClass * currentObjectStreamClass;
+private:
+ ::java::io::ObjectOutputStream$PutField * currentPutField;
+ jboolean fieldsAlreadyWritten;
+ jboolean replacementEnabled;
+ jboolean isSerializing;
+ jint nextOID;
+ ::gnu::java::io::ObjectIdentityMap2Int * OIDLookupTable;
+ jint protocolVersion;
+ jboolean useSubclassMethod;
+ ::gnu::java::security::action::SetAccessibleAction * setAccessible;
+ jint depth;
+ jboolean dump;
+ static const jboolean DEBUG = 0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectOutputStream__
diff --git a/libjava/java/io/ObjectStreamClass$1.h b/libjava/java/io/ObjectStreamClass$1.h
new file mode 100644
index 000000000..e5c266a3b
--- /dev/null
+++ b/libjava/java/io/ObjectStreamClass$1.h
@@ -0,0 +1,24 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectStreamClass$1__
+#define __java_io_ObjectStreamClass$1__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectStreamClass$1 : public ::java::lang::Object
+{
+
+public: // actually package-private
+ ObjectStreamClass$1(::java::io::ObjectStreamClass *);
+public:
+ virtual jint compare(::java::lang::Object *, ::java::lang::Object *);
+public: // actually package-private
+ ::java::io::ObjectStreamClass * __attribute__((aligned(__alignof__( ::java::lang::Object)))) this$0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectStreamClass$1__
diff --git a/libjava/java/io/ObjectStreamClass$2.h b/libjava/java/io/ObjectStreamClass$2.h
new file mode 100644
index 000000000..16d0499f0
--- /dev/null
+++ b/libjava/java/io/ObjectStreamClass$2.h
@@ -0,0 +1,26 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectStreamClass$2__
+#define __java_io_ObjectStreamClass$2__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectStreamClass$2 : public ::java::lang::Object
+{
+
+public: // actually package-private
+ ObjectStreamClass$2(::java::io::ObjectStreamClass *, ::java::lang::reflect::Constructor *);
+public:
+ virtual ::java::lang::Object * run();
+public: // actually package-private
+ ::java::io::ObjectStreamClass * __attribute__((aligned(__alignof__( ::java::lang::Object)))) this$0;
+private:
+ ::java::lang::reflect::Constructor * val$c;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectStreamClass$2__
diff --git a/libjava/java/io/ObjectStreamClass$InterfaceComparator.h b/libjava/java/io/ObjectStreamClass$InterfaceComparator.h
new file mode 100644
index 000000000..7faddc7d7
--- /dev/null
+++ b/libjava/java/io/ObjectStreamClass$InterfaceComparator.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectStreamClass$InterfaceComparator__
+#define __java_io_ObjectStreamClass$InterfaceComparator__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectStreamClass$InterfaceComparator : public ::java::lang::Object
+{
+
+ ObjectStreamClass$InterfaceComparator();
+public:
+ jint compare(::java::lang::Object *, ::java::lang::Object *);
+public: // actually package-private
+ ObjectStreamClass$InterfaceComparator(::java::io::ObjectStreamClass$InterfaceComparator *);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectStreamClass$InterfaceComparator__
diff --git a/libjava/java/io/ObjectStreamClass$MemberComparator.h b/libjava/java/io/ObjectStreamClass$MemberComparator.h
new file mode 100644
index 000000000..81a8ca486
--- /dev/null
+++ b/libjava/java/io/ObjectStreamClass$MemberComparator.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectStreamClass$MemberComparator__
+#define __java_io_ObjectStreamClass$MemberComparator__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectStreamClass$MemberComparator : public ::java::lang::Object
+{
+
+ ObjectStreamClass$MemberComparator();
+public:
+ jint compare(::java::lang::Object *, ::java::lang::Object *);
+public: // actually package-private
+ ObjectStreamClass$MemberComparator(::java::io::ObjectStreamClass$MemberComparator *);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectStreamClass$MemberComparator__
diff --git a/libjava/java/io/ObjectStreamClass.h b/libjava/java/io/ObjectStreamClass.h
new file mode 100644
index 000000000..34514534b
--- /dev/null
+++ b/libjava/java/io/ObjectStreamClass.h
@@ -0,0 +1,117 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectStreamClass__
+#define __java_io_ObjectStreamClass__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace io
+ {
+ class NullOutputStream;
+ }
+ }
+ }
+}
+
+class java::io::ObjectStreamClass : public ::java::lang::Object
+{
+
+public:
+ static ::java::io::ObjectStreamClass * lookup(::java::lang::Class *);
+public: // actually package-private
+ static ::java::io::ObjectStreamClass * lookupForClassObject(::java::lang::Class *);
+public:
+ virtual ::java::lang::String * getName();
+ virtual ::java::lang::Class * forClass();
+ virtual jlong getSerialVersionUID();
+ virtual JArray< ::java::io::ObjectStreamField * > * getFields();
+ virtual ::java::io::ObjectStreamField * getField(::java::lang::String *);
+ virtual ::java::lang::String * toString();
+public: // actually package-private
+ virtual jboolean hasWriteMethod();
+ virtual jboolean isSerializable();
+ virtual jboolean isExternalizable();
+ virtual jboolean isEnum();
+ virtual ::java::io::ObjectStreamClass * getSuper();
+ virtual JArray< ::java::io::ObjectStreamClass * > * hierarchy();
+ virtual jint getFlags();
+ ObjectStreamClass(::java::lang::String *, jlong, jbyte, JArray< ::java::io::ObjectStreamField * > *);
+ virtual void setClass(::java::lang::Class *, ::java::io::ObjectStreamClass *);
+ virtual void setSuperclass(::java::io::ObjectStreamClass *);
+ virtual void calculateOffsets();
+private:
+ ::java::lang::reflect::Method * findMethod(JArray< ::java::lang::reflect::Method * > *, ::java::lang::String *, JArray< ::java::lang::Class * > *, ::java::lang::Class *, jboolean);
+ static jboolean inSamePackage(::java::lang::Class *, ::java::lang::Class *);
+ static ::java::lang::reflect::Method * findAccessibleMethod(::java::lang::String *, ::java::lang::Class *);
+ static jboolean loadedByBootOrApplicationClassLoader(::java::lang::Class *);
+ void cacheMethods();
+ ObjectStreamClass(::java::lang::Class *);
+ void setFlags(::java::lang::Class *);
+public: // actually package-private
+ virtual void ensureFieldsSet(::java::lang::Class *);
+private:
+ void setFields(::java::lang::Class *);
+ jlong getClassUID(::java::lang::Class *);
+public: // actually package-private
+ virtual jlong getClassUIDFromField(::java::lang::Class *);
+ virtual jlong calculateClassUID(::java::lang::Class *);
+private:
+ JArray< ::java::io::ObjectStreamField * > * getSerialPersistentFields(::java::lang::Class *);
+public: // actually package-private
+ virtual ::java::io::Externalizable * newInstance();
+ static JArray< ::java::io::ObjectStreamField * > * INVALID_FIELDS;
+private:
+ JArray< ::java::io::ObjectStreamClass * > * __attribute__((aligned(__alignof__( ::java::lang::Object)))) hierarchy__;
+public: // actually package-private
+ static JArray< ::java::lang::Class * > * noArgs;
+ static ::java::util::Hashtable * methodCache;
+ static JArray< ::java::lang::Class * > * readObjectSignature;
+ static JArray< ::java::lang::Class * > * writeObjectSignature;
+ static ::java::util::Hashtable * uidCache;
+public:
+ static JArray< ::java::io::ObjectStreamField * > * NO_FIELDS;
+private:
+ static ::java::util::Hashtable * classLookupTable;
+ static ::gnu::java::io::NullOutputStream * nullOutputStream;
+ static ::java::util::Comparator * interfaceComparator;
+ static ::java::util::Comparator * memberComparator;
+ static JArray< ::java::lang::Class * > * writeMethodArgTypes;
+ ::java::io::ObjectStreamClass * superClass;
+ ::java::lang::Class * clazz;
+ ::java::lang::String * name;
+ jlong uid;
+ jbyte flags;
+public: // actually package-private
+ JArray< ::java::io::ObjectStreamField * > * fields;
+ jint primFieldSize;
+ jint objectFieldCount;
+ ::java::lang::reflect::Method * readObjectMethod;
+ ::java::lang::reflect::Method * readResolveMethod;
+ ::java::lang::reflect::Method * writeReplaceMethod;
+ ::java::lang::reflect::Method * writeObjectMethod;
+ jboolean realClassIsSerializable;
+ jboolean realClassIsExternalizable;
+ JArray< ::java::io::ObjectStreamField * > * fieldMapping;
+ ::java::lang::reflect::Constructor * firstNonSerializableParentConstructor;
+private:
+ ::java::lang::reflect::Constructor * constructor;
+public: // actually package-private
+ jboolean isProxyClass;
+private:
+ jboolean fieldsSet;
+ static const jlong serialVersionUID = -6120832682080437368LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectStreamClass__
diff --git a/libjava/java/io/ObjectStreamConstants.h b/libjava/java/io/ObjectStreamConstants.h
new file mode 100644
index 000000000..f4e950873
--- /dev/null
+++ b/libjava/java/io/ObjectStreamConstants.h
@@ -0,0 +1,47 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectStreamConstants__
+#define __java_io_ObjectStreamConstants__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectStreamConstants : public ::java::lang::Object
+{
+
+public:
+ static const jint PROTOCOL_VERSION_1 = 1;
+ static const jint PROTOCOL_VERSION_2 = 2;
+ static const jshort STREAM_MAGIC = -21267;
+ static const jshort STREAM_VERSION = 5;
+ static const jbyte TC_NULL = 112;
+ static const jbyte TC_REFERENCE = 113;
+ static const jbyte TC_CLASSDESC = 114;
+ static const jbyte TC_OBJECT = 115;
+ static const jbyte TC_STRING = 116;
+ static const jbyte TC_ARRAY = 117;
+ static const jbyte TC_CLASS = 118;
+ static const jbyte TC_BLOCKDATA = 119;
+ static const jbyte TC_ENDBLOCKDATA = 120;
+ static const jbyte TC_RESET = 121;
+ static const jbyte TC_BLOCKDATALONG = 122;
+ static const jbyte TC_EXCEPTION = 123;
+ static const jbyte TC_LONGSTRING = 124;
+ static const jbyte TC_PROXYCLASSDESC = 125;
+ static const jbyte TC_ENUM = 126;
+ static const jbyte TC_BASE = 112;
+ static const jbyte TC_MAX = 126;
+ static const jint baseWireHandle = 8257536;
+ static const jbyte SC_WRITE_METHOD = 1;
+ static const jbyte SC_SERIALIZABLE = 2;
+ static const jbyte SC_EXTERNALIZABLE = 4;
+ static const jbyte SC_BLOCK_DATA = 8;
+ static const jbyte SC_ENUM = 16;
+ static ::java::io::SerializablePermission * SUBSTITUTION_PERMISSION;
+ static ::java::io::SerializablePermission * SUBCLASS_IMPLEMENTATION_PERMISSION;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_ObjectStreamConstants__
diff --git a/libjava/java/io/ObjectStreamException.h b/libjava/java/io/ObjectStreamException.h
new file mode 100644
index 000000000..4ce583351
--- /dev/null
+++ b/libjava/java/io/ObjectStreamException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectStreamException__
+#define __java_io_ObjectStreamException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+
+class java::io::ObjectStreamException : public ::java::io::IOException
+{
+
+public: // actually protected
+ ObjectStreamException();
+ ObjectStreamException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = 7260898174833392607LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectStreamException__
diff --git a/libjava/java/io/ObjectStreamField$1.h b/libjava/java/io/ObjectStreamField$1.h
new file mode 100644
index 000000000..e5e897a0a
--- /dev/null
+++ b/libjava/java/io/ObjectStreamField$1.h
@@ -0,0 +1,26 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectStreamField$1__
+#define __java_io_ObjectStreamField$1__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectStreamField$1 : public ::java::lang::Object
+{
+
+public: // actually package-private
+ ObjectStreamField$1(::java::io::ObjectStreamField *, ::java::lang::reflect::Field *);
+public:
+ virtual ::java::lang::Object * run();
+public: // actually package-private
+ ::java::io::ObjectStreamField * __attribute__((aligned(__alignof__( ::java::lang::Object)))) this$0;
+private:
+ ::java::lang::reflect::Field * val$f;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectStreamField$1__
diff --git a/libjava/java/io/ObjectStreamField.h b/libjava/java/io/ObjectStreamField.h
new file mode 100644
index 000000000..5b3116fc1
--- /dev/null
+++ b/libjava/java/io/ObjectStreamField.h
@@ -0,0 +1,67 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_ObjectStreamField__
+#define __java_io_ObjectStreamField__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::ObjectStreamField : public ::java::lang::Object
+{
+
+public: // actually package-private
+ ObjectStreamField(::java::lang::reflect::Field *);
+public:
+ ObjectStreamField(::java::lang::String *, ::java::lang::Class *);
+ ObjectStreamField(::java::lang::String *, ::java::lang::Class *, jboolean);
+public: // actually package-private
+ ObjectStreamField(::java::lang::String *, ::java::lang::String *);
+ virtual void resolveType(::java::lang::ClassLoader *);
+public:
+ virtual ::java::lang::String * getName();
+ virtual ::java::lang::Class * getType();
+ virtual jchar getTypeCode();
+ virtual ::java::lang::String * getTypeString();
+ virtual jint getOffset();
+public: // actually protected
+ virtual void setOffset(jint);
+public:
+ virtual jboolean isUnshared();
+ virtual jboolean isPrimitive();
+ virtual jint compareTo(::java::lang::Object *);
+public: // actually package-private
+ virtual void setPersistent(jboolean);
+ virtual jboolean isPersistent();
+ virtual void setToSet(jboolean);
+ virtual jboolean isToSet();
+ virtual void lookupField(::java::lang::Class *);
+ virtual void checkFieldType();
+public:
+ virtual ::java::lang::String * toString();
+public: // actually package-private
+ virtual void setBooleanField(::java::lang::Object *, jboolean);
+ virtual void setByteField(::java::lang::Object *, jbyte);
+ virtual void setCharField(::java::lang::Object *, jchar);
+ virtual void setShortField(::java::lang::Object *, jshort);
+ virtual void setIntField(::java::lang::Object *, jint);
+ virtual void setLongField(::java::lang::Object *, jlong);
+ virtual void setFloatField(::java::lang::Object *, jfloat);
+ virtual void setDoubleField(::java::lang::Object *, jdouble);
+ virtual void setObjectField(::java::lang::Object *, ::java::lang::Object *);
+private:
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) name;
+ ::java::lang::Class * type;
+ ::java::lang::String * typename$;
+ jint offset;
+ jboolean unshared;
+ jboolean persistent;
+ jboolean toset;
+public: // actually package-private
+ ::java::lang::reflect::Field * field;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_ObjectStreamField__
diff --git a/libjava/java/io/OptionalDataException.h b/libjava/java/io/OptionalDataException.h
new file mode 100644
index 000000000..b12a83909
--- /dev/null
+++ b/libjava/java/io/OptionalDataException.h
@@ -0,0 +1,24 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_OptionalDataException__
+#define __java_io_OptionalDataException__
+
+#pragma interface
+
+#include <java/io/ObjectStreamException.h>
+
+class java::io::OptionalDataException : public ::java::io::ObjectStreamException
+{
+
+public: // actually package-private
+ OptionalDataException(jboolean, jint);
+private:
+ static const jlong serialVersionUID = -8011121865681257820LL;
+public:
+ jboolean __attribute__((aligned(__alignof__( ::java::io::ObjectStreamException)))) eof;
+ jint length;
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_OptionalDataException__
diff --git a/libjava/java/io/OutputStream.h b/libjava/java/io/OutputStream.h
new file mode 100644
index 000000000..28f158511
--- /dev/null
+++ b/libjava/java/io/OutputStream.h
@@ -0,0 +1,26 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_OutputStream__
+#define __java_io_OutputStream__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+
+class java::io::OutputStream : public ::java::lang::Object
+{
+
+public:
+ OutputStream();
+ virtual void write(jint) = 0;
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual void flush();
+ virtual void close();
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_OutputStream__
diff --git a/libjava/java/io/OutputStreamWriter.h b/libjava/java/io/OutputStreamWriter.h
new file mode 100644
index 000000000..8ad6c8e69
--- /dev/null
+++ b/libjava/java/io/OutputStreamWriter.h
@@ -0,0 +1,65 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_OutputStreamWriter__
+#define __java_io_OutputStreamWriter__
+
+#pragma interface
+
+#include <java/io/Writer.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace gcj
+ {
+ namespace convert
+ {
+ class UnicodeToBytes;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class Charset;
+ class CharsetEncoder;
+ }
+ }
+ }
+}
+
+class java::io::OutputStreamWriter : public ::java::io::Writer
+{
+
+ OutputStreamWriter(::java::io::OutputStream *, ::gnu::gcj::convert::UnicodeToBytes *);
+public:
+ OutputStreamWriter(::java::io::OutputStream *, ::java::lang::String *);
+ OutputStreamWriter(::java::io::OutputStream *);
+ OutputStreamWriter(::java::io::OutputStream *, ::java::nio::charset::Charset *);
+ OutputStreamWriter(::java::io::OutputStream *, ::java::nio::charset::CharsetEncoder *);
+ virtual void close();
+ virtual ::java::lang::String * getEncoding();
+ virtual void flush();
+ virtual void write(JArray< jchar > *, jint, jint);
+private:
+ void writeChars(JArray< jchar > *, jint, jint);
+public:
+ virtual void write(::java::lang::String *, jint, jint);
+ virtual void write(jint);
+public: // actually package-private
+ ::java::io::BufferedOutputStream * __attribute__((aligned(__alignof__( ::java::io::Writer)))) out;
+ ::gnu::gcj::convert::UnicodeToBytes * converter;
+private:
+ JArray< jchar > * work;
+ jint wcount;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_OutputStreamWriter__
diff --git a/libjava/java/io/OutputStreamWriter.java b/libjava/java/io/OutputStreamWriter.java
new file mode 100644
index 000000000..aac1684c6
--- /dev/null
+++ b/libjava/java/io/OutputStreamWriter.java
@@ -0,0 +1,347 @@
+/* OutputStreamWriter.java -- Writer that converts chars to bytes
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.gcj.convert.UnicodeToBytes;
+import gnu.gcj.convert.CharsetToBytesAdaptor;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+
+/**
+ * This class writes characters to an output stream that is byte oriented
+ * It converts the chars that are written to bytes using an encoding layer,
+ * which is specific to a particular encoding standard. The desired
+ * encoding can either be specified by name, or if no encoding is specified,
+ * the system default encoding will be used. The system default encoding
+ * name is determined from the system property <code>file.encoding</code>.
+ * The only encodings that are guaranteed to be available are "8859_1"
+ * (the Latin-1 character set) and "UTF8". Unfortunately, Java does not
+ * provide a mechanism for listing the encodings that are supported in
+ * a given implementation.
+ * <p>
+ * Here is a list of standard encoding names that may be available:
+ * <p>
+ * <ul>
+ * <li>8859_1 (ISO-8859-1/Latin-1)
+ * <li>8859_2 (ISO-8859-2/Latin-2)
+ * <li>8859_3 (ISO-8859-3/Latin-3)
+ * <li>8859_4 (ISO-8859-4/Latin-4)
+ * <li>8859_5 (ISO-8859-5/Latin-5)
+ * <li>8859_6 (ISO-8859-6/Latin-6)
+ * <li>8859_7 (ISO-8859-7/Latin-7)
+ * <li>8859_8 (ISO-8859-8/Latin-8)
+ * <li>8859_9 (ISO-8859-9/Latin-9)
+ * <li>ASCII (7-bit ASCII)
+ * <li>UTF8 (UCS Transformation Format-8)
+ * <li>More Later
+ * </ul>
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Per Bothner (bothner@cygnus.com)
+ * @date April 17, 1998.
+ */
+public class OutputStreamWriter extends Writer
+{
+ BufferedOutputStream out;
+
+ /**
+ * This is the byte-character encoder class that does the writing and
+ * translation of characters to bytes before writing to the underlying
+ * class.
+ */
+ UnicodeToBytes converter;
+
+ /* Temporary buffer. */
+ private char[] work;
+ private int wcount;
+
+ private OutputStreamWriter(OutputStream out, UnicodeToBytes encoder)
+ {
+ this.out = out instanceof BufferedOutputStream
+ ? (BufferedOutputStream) out
+ : new BufferedOutputStream(out, 250);
+ /* Don't need to call super(out) here as long as the lock gets set. */
+ this.lock = out;
+ this.converter = encoder;
+ }
+
+ /**
+ * This method initializes a new instance of <code>OutputStreamWriter</code>
+ * to write to the specified stream using a caller supplied character
+ * encoding scheme. Note that due to a deficiency in the Java language
+ * design, there is no way to determine which encodings are supported.
+ *
+ * @param out The <code>OutputStream</code> to write to
+ * @param encoding_scheme The name of the encoding scheme to use for
+ * character to byte translation
+ *
+ * @exception UnsupportedEncodingException If the named encoding is
+ * not available.
+ */
+ public OutputStreamWriter (OutputStream out, String encoding_scheme)
+ throws UnsupportedEncodingException
+ {
+ this(out, UnicodeToBytes.getEncoder(encoding_scheme));
+ }
+
+ /**
+ * This method initializes a new instance of <code>OutputStreamWriter</code>
+ * to write to the specified stream using the default encoding.
+ *
+ * @param out The <code>OutputStream</code> to write to
+ */
+ public OutputStreamWriter (OutputStream out)
+ {
+ this(out, UnicodeToBytes.getDefaultEncoder());
+ }
+
+ /**
+ * This method initializes a new instance of <code>OutputStreamWriter</code>
+ * to write to the specified stream using a given <code>Charset</code>.
+ *
+ * @param out The <code>OutputStream</code> to write to
+ * @param cs The <code>Charset</code> of the encoding to use
+ */
+ public OutputStreamWriter(OutputStream out, Charset cs)
+ {
+ this(out, new CharsetToBytesAdaptor(cs));
+ }
+
+ /**
+ * This method initializes a new instance of <code>OutputStreamWriter</code>
+ * to write to the specified stream using a given
+ * <code>CharsetEncoder</code>.
+ *
+ * @param out The <code>OutputStream</code> to write to
+ * @param enc The <code>CharsetEncoder</code> to encode the output with
+ */
+ public OutputStreamWriter(OutputStream out, CharsetEncoder enc)
+ {
+ this(out, new CharsetToBytesAdaptor(enc));
+ }
+
+ /**
+ * This method closes this stream, and the underlying
+ * <code>OutputStream</code>
+ *
+ * @exception IOException If an error occurs
+ */
+ public void close () throws IOException
+ {
+ synchronized (lock)
+ {
+ if (out != null)
+ {
+ converter.setFinished();
+ flush();
+ out.close();
+ out = null;
+ }
+ work = null;
+ }
+ }
+
+ /**
+ * This method returns the name of the character encoding scheme currently
+ * in use by this stream. If the stream has been closed, then this method
+ * may return <code>null</code>.
+ *
+ * @return The encoding scheme name
+ */
+ public String getEncoding ()
+ {
+ return out != null ? converter.getName() : null;
+ }
+
+ /**
+ * This method flushes any buffered bytes to the underlying output sink.
+ *
+ * @exception IOException If an error occurs
+ */
+ public void flush () throws IOException
+ {
+ synchronized (lock)
+ {
+ if (out == null)
+ throw new IOException("Stream closed");
+
+ // Always write -- if we are close()ing then we want to make
+ // sure the converter is flushed.
+ if (work == null)
+ work = new char[100];
+ writeChars(work, 0, wcount);
+ wcount = 0;
+
+ out.flush();
+ }
+ }
+
+ /**
+ * This method writes <code>count</code> characters from the specified
+ * array to the output stream starting at position <code>offset</code>
+ * into the array.
+ *
+ * @param buf The array of character to write from
+ * @param offset The offset into the array to start writing chars from
+ * @param count The number of chars to write.
+ *
+ * @exception IOException If an error occurs
+ */
+ public void write (char[] buf, int offset, int count) throws IOException
+ {
+ synchronized (lock)
+ {
+ if (out == null)
+ throw new IOException("Stream closed");
+
+ if (wcount > 0)
+ {
+ writeChars(work, 0, wcount);
+ wcount = 0;
+ }
+ writeChars(buf, offset, count);
+ }
+ }
+
+ /*
+ * Writes characters through to the inferior BufferedOutputStream.
+ * Ignores wcount and the work buffer.
+ */
+ private void writeChars(char[] buf, int offset, int count)
+ throws IOException
+ {
+ do
+ {
+ // We must flush if out.count == out.buf.length.
+ // It is probably a good idea to flush if out.buf is almost full.
+ // This test is an approximation for "almost full".
+ if (out.count + count >= out.buf.length)
+ {
+ out.flush();
+ if (out.count != 0)
+ throw new IOException("unable to flush output byte buffer");
+ }
+ converter.setOutput(out.buf, out.count);
+ int converted = converter.write(buf, offset, count);
+ // Must set this before we flush the output stream, because
+ // flushing will reset 'out.count'.
+ out.count = converter.count;
+ // Flush if we cannot make progress.
+ if (converted == 0 && out.count == converter.count)
+ {
+ out.flush();
+ if (out.count != 0)
+ throw new IOException("unable to flush output byte buffer");
+ }
+ offset += converted;
+ count -= converted;
+ }
+ while (count > 0 || converter.havePendingBytes());
+ }
+
+ /**
+ * This method writes <code>count</code> bytes from the specified
+ * <code>String</code> starting at position <code>offset</code> into the
+ * <code>String</code>.
+ *
+ * @param str The <code>String</code> to write chars from
+ * @param offset The position in the <code>String</code> to start
+ * writing chars from
+ * @param count The number of chars to write
+ *
+ * @exception IOException If an error occurs
+ */
+ public void write (String str, int offset, int count) throws IOException
+ {
+ synchronized (lock)
+ {
+ if (out == null)
+ throw new IOException("Stream closed");
+
+ if (work == null)
+ work = new char[100];
+ int wlength = work.length;
+ while (count > 0)
+ {
+ int size = count;
+ if (wcount + size > wlength)
+ {
+ if (2*wcount > wlength)
+ {
+ writeChars(work, 0, wcount);
+ wcount = 0;
+ }
+ if (wcount + size > wlength)
+ size = wlength - wcount;
+ }
+ str.getChars(offset, offset+size, work, wcount);
+ offset += size;
+ count -= size;
+ wcount += size;
+ }
+ }
+ }
+
+ /**
+ * This method writes a single character to the output stream.
+ *
+ * @param ch The char to write, passed as an int.
+ *
+ * @exception IOException If an error occurs
+ */
+ public void write (int ch) throws IOException
+ {
+ synchronized (lock)
+ {
+ if (out == null)
+ throw new IOException("Stream closed");
+
+ if (work == null)
+ work = new char[100];
+ if (wcount >= work.length)
+ {
+ writeChars(work, 0, wcount);
+ wcount = 0;
+ }
+ work[wcount++] = (char) ch;
+ }
+ }
+
+} // class OutputStreamWriter
+
diff --git a/libjava/java/io/PipedInputStream.h b/libjava/java/io/PipedInputStream.h
new file mode 100644
index 000000000..4055fa4ca
--- /dev/null
+++ b/libjava/java/io/PipedInputStream.h
@@ -0,0 +1,45 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_PipedInputStream__
+#define __java_io_PipedInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::PipedInputStream : public ::java::io::InputStream
+{
+
+public:
+ PipedInputStream();
+ PipedInputStream(jint);
+ PipedInputStream(::java::io::PipedOutputStream *);
+ PipedInputStream(::java::io::PipedOutputStream *, jint);
+ virtual void connect(::java::io::PipedOutputStream *);
+public: // actually protected
+ virtual void receive(jint);
+public: // actually package-private
+ virtual void receive(JArray< jbyte > *, jint, jint);
+public:
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual jint available();
+ virtual void close();
+public: // actually package-private
+ ::java::io::PipedOutputStream * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) source;
+ jboolean closed;
+public: // actually protected
+ static const jint PIPE_SIZE = 1024;
+ JArray< jbyte > * buffer;
+ jint in;
+ jint out;
+private:
+ JArray< jbyte > * read_buf;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_PipedInputStream__
diff --git a/libjava/java/io/PipedOutputStream.h b/libjava/java/io/PipedOutputStream.h
new file mode 100644
index 000000000..79e069e40
--- /dev/null
+++ b/libjava/java/io/PipedOutputStream.h
@@ -0,0 +1,31 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_PipedOutputStream__
+#define __java_io_PipedOutputStream__
+
+#pragma interface
+
+#include <java/io/OutputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::PipedOutputStream : public ::java::io::OutputStream
+{
+
+public:
+ PipedOutputStream();
+ PipedOutputStream(::java::io::PipedInputStream *);
+ virtual void connect(::java::io::PipedInputStream *);
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual void flush();
+ virtual void close();
+public: // actually package-private
+ ::java::io::PipedInputStream * __attribute__((aligned(__alignof__( ::java::io::OutputStream)))) sink;
+ jboolean closed;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_PipedOutputStream__
diff --git a/libjava/java/io/PipedReader.h b/libjava/java/io/PipedReader.h
new file mode 100644
index 000000000..1eac2f79e
--- /dev/null
+++ b/libjava/java/io/PipedReader.h
@@ -0,0 +1,39 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_PipedReader__
+#define __java_io_PipedReader__
+
+#pragma interface
+
+#include <java/io/Reader.h>
+#include <gcj/array.h>
+
+
+class java::io::PipedReader : public ::java::io::Reader
+{
+
+public:
+ PipedReader();
+ PipedReader(::java::io::PipedWriter *);
+ virtual void connect(::java::io::PipedWriter *);
+public: // actually package-private
+ virtual void receive(JArray< jchar > *, jint, jint);
+public:
+ virtual jint read();
+ virtual jint read(JArray< jchar > *, jint, jint);
+ virtual jboolean ready();
+ virtual void close();
+public: // actually package-private
+ ::java::io::PipedWriter * __attribute__((aligned(__alignof__( ::java::io::Reader)))) source;
+ jboolean closed;
+ static const jint PIPE_SIZE = 2048;
+ JArray< jchar > * buffer;
+ jint in;
+ jint out;
+ JArray< jchar > * read_buf;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_PipedReader__
diff --git a/libjava/java/io/PipedWriter.h b/libjava/java/io/PipedWriter.h
new file mode 100644
index 000000000..d1aac55ae
--- /dev/null
+++ b/libjava/java/io/PipedWriter.h
@@ -0,0 +1,32 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_PipedWriter__
+#define __java_io_PipedWriter__
+
+#pragma interface
+
+#include <java/io/Writer.h>
+#include <gcj/array.h>
+
+
+class java::io::PipedWriter : public ::java::io::Writer
+{
+
+public:
+ PipedWriter();
+ PipedWriter(::java::io::PipedReader *);
+ virtual void connect(::java::io::PipedReader *);
+ virtual void write(jint);
+ virtual void write(JArray< jchar > *, jint, jint);
+ virtual void flush();
+ virtual void close();
+public: // actually package-private
+ ::java::io::PipedReader * __attribute__((aligned(__alignof__( ::java::io::Writer)))) sink;
+ jboolean closed;
+ JArray< jchar > * read_buf;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_PipedWriter__
diff --git a/libjava/java/io/PrintStream.h b/libjava/java/io/PrintStream.h
new file mode 100644
index 000000000..6247ba829
--- /dev/null
+++ b/libjava/java/io/PrintStream.h
@@ -0,0 +1,93 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_PrintStream__
+#define __java_io_PrintStream__
+
+#pragma interface
+
+#include <java/io/FilterOutputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace gcj
+ {
+ namespace convert
+ {
+ class UnicodeToBytes;
+ }
+ }
+ }
+}
+
+class java::io::PrintStream : public ::java::io::FilterOutputStream
+{
+
+public:
+ PrintStream(::java::io::OutputStream *);
+ PrintStream(::java::io::OutputStream *, jboolean);
+ PrintStream(::java::io::File *);
+ PrintStream(::java::io::File *, ::java::lang::String *);
+ PrintStream(::java::lang::String *);
+ PrintStream(::java::lang::String *, ::java::lang::String *);
+ PrintStream(::java::io::OutputStream *, jboolean, ::java::lang::String *);
+ virtual jboolean checkError();
+public: // actually protected
+ virtual void setError();
+public:
+ virtual void close();
+ virtual void flush();
+private:
+ void print(::java::lang::String *, jboolean);
+ void print(JArray< jchar > *, jint, jint, jboolean);
+ void writeChars(JArray< jchar > *, jint, jint);
+ void writeChars(::java::lang::String *, jint, jint);
+public:
+ virtual void print(jboolean);
+ virtual void print(jint);
+ virtual void print(jlong);
+ virtual void print(jfloat);
+ virtual void print(jdouble);
+ virtual void print(::java::lang::Object *);
+ virtual void print(::java::lang::String *);
+ virtual void print(jchar);
+ virtual void print(JArray< jchar > *);
+ virtual void println();
+ virtual void println(jboolean);
+ virtual void println(jint);
+ virtual void println(jlong);
+ virtual void println(jfloat);
+ virtual void println(jdouble);
+ virtual void println(::java::lang::Object *);
+ virtual void println(::java::lang::String *);
+ virtual void println(jchar);
+ virtual void println(JArray< jchar > *);
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual ::java::io::PrintStream * PrintStream$append(jchar);
+ virtual ::java::io::PrintStream * PrintStream$append(::java::lang::CharSequence *);
+ virtual ::java::io::PrintStream * PrintStream$append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::io::PrintStream * printf(::java::lang::String *, JArray< ::java::lang::Object * > *);
+ virtual ::java::io::PrintStream * printf(::java::util::Locale *, ::java::lang::String *, JArray< ::java::lang::Object * > *);
+ virtual ::java::io::PrintStream * format(::java::lang::String *, JArray< ::java::lang::Object * > *);
+ virtual ::java::io::PrintStream * format(::java::util::Locale *, ::java::lang::String *, JArray< ::java::lang::Object * > *);
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *);
+ virtual ::java::lang::Appendable * append(jchar);
+private:
+ static JArray< jchar > * line_separator;
+public: // actually package-private
+ ::gnu::gcj::convert::UnicodeToBytes * __attribute__((aligned(__alignof__( ::java::io::FilterOutputStream)))) converter;
+ JArray< jchar > * work;
+ JArray< jbyte > * work_bytes;
+private:
+ jboolean error_occurred;
+ jboolean auto_flush;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_PrintStream__
diff --git a/libjava/java/io/PrintStream.java b/libjava/java/io/PrintStream.java
new file mode 100644
index 000000000..be2861905
--- /dev/null
+++ b/libjava/java/io/PrintStream.java
@@ -0,0 +1,684 @@
+/* PrintStream.java -- OutputStream for printing output
+ Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import java.util.Formatter;
+import java.util.Locale;
+
+import gnu.gcj.convert.UnicodeToBytes;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * Status: Believed complete and correct to 1.3
+ */
+
+/**
+ * This class prints Java primitive values and object to a stream as
+ * text. None of the methods in this class throw an exception. However,
+ * errors can be detected by calling the <code>checkError()</code> method.
+ * Additionally, this stream can be designated as "autoflush" when
+ * created so that any writes are automatically flushed to the underlying
+ * output sink when the current line is terminated.
+ * <p>
+ * This class converts char's into byte's using the system default encoding.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Tom Tromey (tromey@cygnus.com)
+ */
+public class PrintStream extends FilterOutputStream implements Appendable
+{
+ /* Notice the implementation is quite similar to OutputStreamWriter.
+ * This leads to some minor duplication, because neither inherits
+ * from the other, and we want to maximize performance. */
+
+ // Line separator string.
+ private static final char[] line_separator
+ = System.getProperty("line.separator").toCharArray();
+
+ UnicodeToBytes converter;
+
+ // Work buffer of characters for converter.
+ char[] work = new char[100];
+ // Work buffer of bytes where we temporarily keep converter output.
+ byte[] work_bytes = new byte[100];
+
+ /**
+ * This boolean indicates whether or not an error has ever occurred
+ * on this stream.
+ */
+ private boolean error_occurred = false;
+
+ /**
+ * This is <code>true</code> if auto-flush is enabled,
+ * <code>false</code> otherwise
+ */
+ private boolean auto_flush;
+
+ /**
+ * This method intializes a new <code>PrintStream</code> object to write
+ * to the specified output sink.
+ *
+ * @param out The <code>OutputStream</code> to write to.
+ */
+ public PrintStream (OutputStream out)
+ {
+ this (out, false);
+ }
+
+ /**
+ * This method intializes a new <code>PrintStream</code> object to write
+ * to the specified output sink. This constructor also allows "auto-flush"
+ * functionality to be specified where the stream will be flushed after
+ * every <code>print</code> or <code>println</code> call, when the
+ * <code>write</code> methods with array arguments are called, or when a
+ * single new-line character is written.
+ * <p>
+ *
+ * @param out The <code>OutputStream</code> to write to.
+ * @param auto_flush <code>true</code> to flush the stream after every
+ * line, <code>false</code> otherwise
+ */
+ public PrintStream (OutputStream out, boolean auto_flush)
+ {
+ super (out);
+
+ converter = UnicodeToBytes.getDefaultEncoder();
+ this.auto_flush = auto_flush;
+ }
+
+ /**
+ * This method initializes a new <code>PrintStream</code> object to write
+ * to the specified output File. Doesn't autoflush.
+ *
+ * @param file The <code>File</code> to write to.
+ * @throws FileNotFoundException if an error occurs while opening the file.
+ *
+ * @since 1.5
+ */
+ public PrintStream (File file)
+ throws FileNotFoundException
+ {
+ this (new FileOutputStream(file), false);
+ }
+
+ /**
+ * This method initializes a new <code>PrintStream</code> object to write
+ * to the specified output File. Doesn't autoflush.
+ *
+ * @param file The <code>File</code> to write to.
+ * @param encoding The name of the character encoding to use for this
+ * object.
+ * @throws FileNotFoundException If an error occurs while opening the file.
+ * @throws UnsupportedEncodingException If the charset specified by
+ * <code>encoding</code> is invalid.
+ *
+ * @since 1.5
+ */
+ public PrintStream (File file, String encoding)
+ throws FileNotFoundException,UnsupportedEncodingException
+ {
+ this (new FileOutputStream(file), false, encoding);
+ }
+
+ /**
+ * This method initializes a new <code>PrintStream</code> object to write
+ * to the specified output File. Doesn't autoflush.
+ *
+ * @param fileName The name of the <code>File</code> to write to.
+ * @throws FileNotFoundException if an error occurs while opening the file,
+ *
+ * @since 1.5
+ */
+ public PrintStream (String fileName)
+ throws FileNotFoundException
+ {
+ this (new FileOutputStream(new File(fileName)), false);
+ }
+
+ /**
+ * This method initializes a new <code>PrintStream</code> object to write
+ * to the specified output File. Doesn't autoflush.
+ *
+ * @param fileName The name of the <code>File</code> to write to.
+ * @param encoding The name of the character encoding to use for this
+ * object.
+ * @throws FileNotFoundException if an error occurs while opening the file.
+ * @throws UnsupportedEncodingException If the charset specified by
+ * <code>encoding</code> is invalid.
+ *
+ * @since 1.5
+ */
+ public PrintStream (String fileName, String encoding)
+ throws FileNotFoundException,UnsupportedEncodingException
+ {
+ this (new FileOutputStream(new File(fileName)), false, encoding);
+ }
+
+ /**
+ * This method intializes a new <code>PrintStream</code> object to write
+ * to the specified output sink. This constructor also allows "auto-flush"
+ * functionality to be specified where the stream will be flushed after
+ * every <code>print</code> or <code>println</code> call, when the
+ * <code>write</code> methods with array arguments are called, or when a
+ * single new-line character is written.
+ * <p>
+ *
+ * @param out The <code>OutputStream</code> to write to.
+ * @param auto_flush <code>true</code> to flush the stream after every
+ * line, <code>false</code> otherwise
+ * @param encoding The name of the character encoding to use for this
+ * object.
+ */
+ public PrintStream (OutputStream out, boolean auto_flush, String encoding)
+ throws UnsupportedEncodingException
+ {
+ super (out);
+
+ converter = UnicodeToBytes.getEncoder (encoding);
+ this.auto_flush = auto_flush;
+ }
+
+ /**
+ * This method checks to see if an error has occurred on this stream. Note
+ * that once an error has occurred, this method will continue to report
+ * <code>true</code> forever for this stream. Before checking for an
+ * error condition, this method flushes the stream.
+ *
+ * @return <code>true</code> if an error has occurred,
+ * <code>false</code> otherwise
+ */
+ public boolean checkError ()
+ {
+ flush ();
+ return error_occurred;
+ }
+
+ /**
+ * This method can be called by subclasses to indicate that an error
+ * has occurred and should be reported by <code>checkError</code>.
+ */
+ protected void setError ()
+ {
+ error_occurred = true;
+ }
+
+ /**
+ * This method closes this stream and all underlying streams.
+ */
+ public void close ()
+ {
+ try
+ {
+ converter.setFinished();
+ writeChars(new char[0], 0, 0);
+ flush();
+ out.close();
+ }
+ catch (InterruptedIOException iioe)
+ {
+ Thread.currentThread().interrupt();
+ }
+ catch (IOException e)
+ {
+ setError ();
+ }
+ }
+
+ /**
+ * This method flushes any buffered bytes to the underlying stream and
+ * then flushes that stream as well.
+ */
+ public void flush ()
+ {
+ try
+ {
+ out.flush();
+ }
+ catch (InterruptedIOException iioe)
+ {
+ Thread.currentThread().interrupt();
+ }
+ catch (IOException e)
+ {
+ setError ();
+ }
+ }
+
+ private synchronized void print (String str, boolean println)
+ {
+ try
+ {
+ writeChars(str, 0, str.length());
+ if (println)
+ writeChars(line_separator, 0, line_separator.length);
+ if (auto_flush)
+ flush();
+ }
+ catch (InterruptedIOException iioe)
+ {
+ Thread.currentThread().interrupt();
+ }
+ catch (IOException e)
+ {
+ setError ();
+ }
+ }
+
+ private synchronized void print (char[] chars, int pos, int len,
+ boolean println)
+ {
+ try
+ {
+ writeChars(chars, pos, len);
+ if (println)
+ writeChars(line_separator, 0, line_separator.length);
+ if (auto_flush)
+ flush();
+ }
+ catch (InterruptedIOException iioe)
+ {
+ Thread.currentThread().interrupt();
+ }
+ catch (IOException e)
+ {
+ setError ();
+ }
+ }
+
+ private void writeChars(char[] buf, int offset, int count)
+ throws IOException
+ {
+ do
+ {
+ converter.setOutput(work_bytes, 0);
+ int converted = converter.write(buf, offset, count);
+ offset += converted;
+ count -= converted;
+ out.write(work_bytes, 0, converter.count);
+ }
+ while (count > 0 || converter.havePendingBytes());
+ }
+
+ private void writeChars(String str, int offset, int count)
+ throws IOException
+ {
+ do
+ {
+ converter.setOutput(work_bytes, 0);
+ int converted = converter.write(str, offset, count, work);
+ offset += converted;
+ count -= converted;
+ out.write(work_bytes, 0, converter.count);
+ }
+ while (count > 0 || converter.havePendingBytes());
+ }
+
+ /**
+ * This methods prints a boolean value to the stream. <code>true</code>
+ * values are printed as "true" and <code>false</code> values are printed
+ * as "false".
+ *
+ * @param bool The <code>boolean</code> value to print
+ */
+ public void print (boolean bool)
+ {
+ print(String.valueOf(bool), false);
+ }
+
+ /**
+ * This method prints an integer to the stream. The value printed is
+ * determined using the <code>String.valueOf()</code> method.
+ *
+ * @param inum The <code>int</code> value to be printed
+ */
+ public void print (int inum)
+ {
+ print(String.valueOf(inum), false);
+ }
+
+ /**
+ * This method prints a long to the stream. The value printed is
+ * determined using the <code>String.valueOf()</code> method.
+ *
+ * @param lnum The <code>long</code> value to be printed
+ */
+ public void print (long lnum)
+ {
+ print(String.valueOf(lnum), false);
+ }
+
+ /**
+ * This method prints a float to the stream. The value printed is
+ * determined using the <code>String.valueOf()</code> method.
+ *
+ * @param fnum The <code>float</code> value to be printed
+ */
+ public void print (float fnum)
+ {
+ print(String.valueOf(fnum), false);
+ }
+
+ /**
+ * This method prints a double to the stream. The value printed is
+ * determined using the <code>String.valueOf()</code> method.
+ *
+ * @param dnum The <code>double</code> value to be printed
+ */
+ public void print (double dnum)
+ {
+ print(String.valueOf(dnum), false);
+ }
+
+ /**
+ * This method prints an <code>Object</code> to the stream. The actual
+ * value printed is determined by calling the <code>String.valueOf()</code>
+ * method.
+ *
+ * @param obj The <code>Object</code> to print.
+ */
+ public void print (Object obj)
+ {
+ print(obj == null ? "null" : obj.toString(), false);
+ }
+
+ /**
+ * This method prints a <code>String</code> to the stream. The actual
+ * value printed depends on the system default encoding.
+ *
+ * @param str The <code>String</code> to print.
+ */
+ public void print (String str)
+ {
+ print(str == null ? "null" : str, false);
+ }
+
+ /**
+ * This method prints a char to the stream. The actual value printed is
+ * determined by the character encoding in use.
+ *
+ * @param ch The <code>char</code> value to be printed
+ */
+ public synchronized void print (char ch)
+ {
+ work[0] = ch;
+ print(work, 0, 1, false);
+ }
+
+ /**
+ * This method prints an array of characters to the stream. The actual
+ * value printed depends on the system default encoding.
+ *
+ * @param charArray The array of characters to print.
+ */
+ public void print (char[] charArray)
+ {
+ print(charArray, 0, charArray.length, false);
+ }
+
+ /**
+ * This method prints a line separator sequence to the stream. The value
+ * printed is determined by the system property <xmp>line.separator</xmp>
+ * and is not necessarily the Unix '\n' newline character.
+ */
+ public void println ()
+ {
+ print(line_separator, 0, line_separator.length, false);
+ }
+
+ /**
+ * This methods prints a boolean value to the stream. <code>true</code>
+ * values are printed as "true" and <code>false</code> values are printed
+ * as "false".
+ * <p>
+ * This method prints a line termination sequence after printing the value.
+ *
+ * @param bool The <code>boolean</code> value to print
+ */
+ public void println (boolean bool)
+ {
+ print(String.valueOf(bool), true);
+ }
+
+ /**
+ * This method prints an integer to the stream. The value printed is
+ * determined using the <code>String.valueOf()</code> method.
+ * <p>
+ * This method prints a line termination sequence after printing the value.
+ *
+ * @param inum The <code>int</code> value to be printed
+ */
+ public void println (int inum)
+ {
+ print(String.valueOf(inum), true);
+ }
+
+ /**
+ * This method prints a long to the stream. The value printed is
+ * determined using the <code>String.valueOf()</code> method.
+ * <p>
+ * This method prints a line termination sequence after printing the value.
+ *
+ * @param lnum The <code>long</code> value to be printed
+ */
+ public void println (long lnum)
+ {
+ print(String.valueOf(lnum), true);
+ }
+
+ /**
+ * This method prints a float to the stream. The value printed is
+ * determined using the <code>String.valueOf()</code> method.
+ * <p>
+ * This method prints a line termination sequence after printing the value.
+ *
+ * @param fnum The <code>float</code> value to be printed
+ */
+ public void println (float fnum)
+ {
+ print(String.valueOf(fnum), true);
+ }
+
+ /**
+ * This method prints a double to the stream. The value printed is
+ * determined using the <code>String.valueOf()</code> method.
+ * <p>
+ * This method prints a line termination sequence after printing the value.
+ *
+ * @param dnum The <code>double</code> value to be printed
+ */
+ public void println (double dnum)
+ {
+ print(String.valueOf(dnum), true);
+ }
+
+ /**
+ * This method prints an <code>Object</code> to the stream. The actual
+ * value printed is determined by calling the <code>String.valueOf()</code>
+ * method.
+ * <p>
+ * This method prints a line termination sequence after printing the value.
+ *
+ * @param obj The <code>Object</code> to print.
+ */
+ public void println (Object obj)
+ {
+ print(obj == null ? "null" : obj.toString(), true);
+ }
+
+ /**
+ * This method prints a <code>String</code> to the stream. The actual
+ * value printed depends on the system default encoding.
+ * <p>
+ * This method prints a line termination sequence after printing the value.
+ *
+ * @param str The <code>String</code> to print.
+ */
+ public void println (String str)
+ {
+ print (str == null ? "null" : str, true);
+ }
+
+ /**
+ * This method prints a char to the stream. The actual value printed is
+ * determined by the character encoding in use.
+ * <p>
+ * This method prints a line termination sequence after printing the value.
+ *
+ * @param ch The <code>char</code> value to be printed
+ */
+ public synchronized void println (char ch)
+ {
+ work[0] = ch;
+ print(work, 0, 1, true);
+ }
+
+ /**
+ * This method prints an array of characters to the stream. The actual
+ * value printed depends on the system default encoding.
+ * <p>
+ * This method prints a line termination sequence after printing the value.
+ *
+ * @param charArray The array of characters to print.
+ */
+ public void println (char[] charArray)
+ {
+ print(charArray, 0, charArray.length, true);
+ }
+
+ /**
+ * This method writes a byte of data to the stream. If auto-flush is
+ * enabled, printing a newline character will cause the stream to be
+ * flushed after the character is written.
+ *
+ * @param oneByte The byte to be written
+ */
+ public void write (int oneByte)
+ {
+ try
+ {
+ out.write (oneByte & 0xff);
+
+ if (auto_flush && (oneByte == '\n'))
+ flush ();
+ }
+ catch (InterruptedIOException iioe)
+ {
+ Thread.currentThread ().interrupt ();
+ }
+ catch (IOException e)
+ {
+ setError ();
+ }
+ }
+
+ /**
+ * This method writes <code>len</code> bytes from the specified array
+ * starting at index <code>offset</code> into the array.
+ *
+ * @param buffer The array of bytes to write
+ * @param offset The index into the array to start writing from
+ * @param len The number of bytes to write
+ */
+ public void write (byte[] buffer, int offset, int len)
+ {
+ try
+ {
+ out.write (buffer, offset, len);
+
+ if (auto_flush)
+ flush ();
+ }
+ catch (InterruptedIOException iioe)
+ {
+ Thread.currentThread ().interrupt ();
+ }
+ catch (IOException e)
+ {
+ setError ();
+ }
+ }
+
+ /** @since 1.5 */
+ public PrintStream append(char c)
+ {
+ print(c);
+ return this;
+ }
+
+ /** @since 1.5 */
+ public PrintStream append(CharSequence cs)
+ {
+ print(cs == null ? "null" : cs.toString());
+ return this;
+ }
+
+ /** @since 1.5 */
+ public PrintStream append(CharSequence cs, int start, int end)
+ {
+ print(cs == null ? "null" : cs.subSequence(start, end).toString());
+ return this;
+ }
+
+ /** @since 1.5 */
+ public PrintStream printf(String format, Object... args)
+ {
+ return format(format, args);
+ }
+
+ /** @since 1.5 */
+ public PrintStream printf(Locale locale, String format, Object... args)
+ {
+ return format(locale, format, args);
+ }
+
+ /** @since 1.5 */
+ public PrintStream format(String format, Object... args)
+ {
+ return format(Locale.getDefault(), format, args);
+ }
+
+ /** @since 1.5 */
+ public PrintStream format(Locale locale, String format, Object... args)
+ {
+ Formatter f = new Formatter(this, locale);
+ f.format(format, args);
+ return this;
+ }
+} // class PrintStream
+
diff --git a/libjava/java/io/PrintWriter.h b/libjava/java/io/PrintWriter.h
new file mode 100644
index 000000000..cf1fb324a
--- /dev/null
+++ b/libjava/java/io/PrintWriter.h
@@ -0,0 +1,80 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_PrintWriter__
+#define __java_io_PrintWriter__
+
+#pragma interface
+
+#include <java/io/Writer.h>
+#include <gcj/array.h>
+
+
+class java::io::PrintWriter : public ::java::io::Writer
+{
+
+public:
+ PrintWriter(::java::io::Writer *);
+ PrintWriter(::java::io::Writer *, jboolean);
+ PrintWriter(::java::io::OutputStream *);
+ PrintWriter(::java::io::OutputStream *, jboolean);
+ PrintWriter(::java::lang::String *);
+ PrintWriter(::java::lang::String *, ::java::lang::String *);
+ PrintWriter(::java::io::File *);
+ PrintWriter(::java::io::File *, ::java::lang::String *);
+public: // actually protected
+ virtual void setError();
+public:
+ virtual jboolean checkError();
+ virtual void flush();
+ virtual void close();
+ virtual void print(::java::lang::String *);
+ virtual void print(jchar);
+ virtual void print(JArray< jchar > *);
+ virtual void print(jboolean);
+ virtual void print(jint);
+ virtual void print(jlong);
+ virtual void print(jfloat);
+ virtual void print(jdouble);
+ virtual void print(::java::lang::Object *);
+ virtual void println();
+ virtual void println(jboolean);
+ virtual void println(jint);
+ virtual void println(jlong);
+ virtual void println(jfloat);
+ virtual void println(jdouble);
+ virtual void println(::java::lang::Object *);
+ virtual void println(::java::lang::String *);
+ virtual void println(jchar);
+ virtual void println(JArray< jchar > *);
+ virtual void write(jint);
+ virtual void write(JArray< jchar > *, jint, jint);
+ virtual void write(::java::lang::String *, jint, jint);
+ virtual void write(JArray< jchar > *);
+ virtual void write(::java::lang::String *);
+ virtual ::java::io::PrintWriter * PrintWriter$append(jchar);
+ virtual ::java::io::PrintWriter * PrintWriter$append(::java::lang::CharSequence *);
+ virtual ::java::io::PrintWriter * PrintWriter$append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::io::PrintWriter * printf(::java::lang::String *, JArray< ::java::lang::Object * > *);
+ virtual ::java::io::PrintWriter * printf(::java::util::Locale *, ::java::lang::String *, JArray< ::java::lang::Object * > *);
+ virtual ::java::io::PrintWriter * format(::java::lang::String *, JArray< ::java::lang::Object * > *);
+ virtual ::java::io::PrintWriter * format(::java::util::Locale *, ::java::lang::String *, JArray< ::java::lang::Object * > *);
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::io::Writer * Writer$append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *);
+ virtual ::java::io::Writer * Writer$append(::java::lang::CharSequence *);
+ virtual ::java::lang::Appendable * append(jchar);
+ virtual ::java::io::Writer * Writer$append(jchar);
+private:
+ jboolean __attribute__((aligned(__alignof__( ::java::io::Writer)))) autoflush;
+ jboolean error;
+ jboolean closed;
+public: // actually protected
+ ::java::io::Writer * out;
+private:
+ static JArray< jchar > * line_separator;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_PrintWriter__
diff --git a/libjava/java/io/PushbackInputStream.h b/libjava/java/io/PushbackInputStream.h
new file mode 100644
index 000000000..032bfce98
--- /dev/null
+++ b/libjava/java/io/PushbackInputStream.h
@@ -0,0 +1,38 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_PushbackInputStream__
+#define __java_io_PushbackInputStream__
+
+#pragma interface
+
+#include <java/io/FilterInputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::PushbackInputStream : public ::java::io::FilterInputStream
+{
+
+public:
+ PushbackInputStream(::java::io::InputStream *);
+ PushbackInputStream(::java::io::InputStream *, jint);
+ virtual jint available();
+ virtual void close();
+ virtual jboolean markSupported();
+ virtual void reset();
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual void unread(jint);
+ virtual void unread(JArray< jbyte > *);
+ virtual void unread(JArray< jbyte > *, jint, jint);
+ virtual jlong skip(jlong);
+private:
+ static const jint DEFAULT_BUFFER_SIZE = 1;
+public: // actually protected
+ JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::io::FilterInputStream)))) buf;
+ jint pos;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_PushbackInputStream__
diff --git a/libjava/java/io/PushbackReader.h b/libjava/java/io/PushbackReader.h
new file mode 100644
index 000000000..8d1c2ee5e
--- /dev/null
+++ b/libjava/java/io/PushbackReader.h
@@ -0,0 +1,38 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_PushbackReader__
+#define __java_io_PushbackReader__
+
+#pragma interface
+
+#include <java/io/FilterReader.h>
+#include <gcj/array.h>
+
+
+class java::io::PushbackReader : public ::java::io::FilterReader
+{
+
+public:
+ PushbackReader(::java::io::Reader *);
+ PushbackReader(::java::io::Reader *, jint);
+ virtual void close();
+ virtual void mark(jint);
+ virtual jboolean markSupported();
+ virtual void reset();
+ virtual jboolean ready();
+ virtual jlong skip(jlong);
+ virtual jint read();
+ virtual jint read(JArray< jchar > *, jint, jint);
+ virtual void unread(jint);
+ virtual void unread(JArray< jchar > *);
+ virtual void unread(JArray< jchar > *, jint, jint);
+private:
+ static const jint DEFAULT_BUFFER_SIZE = 1;
+ JArray< jchar > * __attribute__((aligned(__alignof__( ::java::io::FilterReader)))) buf;
+ jint pos;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_PushbackReader__
diff --git a/libjava/java/io/RandomAccessFile.h b/libjava/java/io/RandomAccessFile.h
new file mode 100644
index 000000000..6b6076dfa
--- /dev/null
+++ b/libjava/java/io/RandomAccessFile.h
@@ -0,0 +1,93 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_RandomAccessFile__
+#define __java_io_RandomAccessFile__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace nio
+ {
+ namespace channels
+ {
+ class FileChannelImpl;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace nio
+ {
+ namespace channels
+ {
+ class FileChannel;
+ }
+ }
+ }
+}
+
+class java::io::RandomAccessFile : public ::java::lang::Object
+{
+
+public:
+ RandomAccessFile(::java::io::File *, ::java::lang::String *);
+ RandomAccessFile(::java::lang::String *, ::java::lang::String *);
+ virtual void close();
+ virtual ::java::io::FileDescriptor * getFD();
+ virtual jlong getFilePointer();
+ virtual void setLength(jlong);
+ virtual jlong length();
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual jboolean readBoolean();
+ virtual jbyte readByte();
+ virtual jchar readChar();
+ virtual jdouble readDouble();
+ virtual jfloat readFloat();
+ virtual void readFully(JArray< jbyte > *);
+ virtual void readFully(JArray< jbyte > *, jint, jint);
+ virtual jint readInt();
+ virtual ::java::lang::String * readLine();
+ virtual jlong readLong();
+ virtual jshort readShort();
+ virtual jint readUnsignedByte();
+ virtual jint readUnsignedShort();
+ virtual ::java::lang::String * readUTF();
+ virtual void seek(jlong);
+ virtual jint skipBytes(jint);
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual void writeBoolean(jboolean);
+ virtual void writeByte(jint);
+ virtual void writeShort(jint);
+ virtual void writeChar(jint);
+ virtual void writeInt(jint);
+ virtual void writeLong(jlong);
+ virtual void writeFloat(jfloat);
+ virtual void writeDouble(jdouble);
+ virtual void writeBytes(::java::lang::String *);
+ virtual void writeChars(::java::lang::String *);
+ virtual void writeUTF(::java::lang::String *);
+ virtual ::java::nio::channels::FileChannel * getChannel();
+private:
+ ::gnu::java::nio::channels::FileChannelImpl * __attribute__((aligned(__alignof__( ::java::lang::Object)))) ch;
+ ::java::io::FileDescriptor * fd;
+ ::java::io::DataOutputStream * out;
+ ::java::io::DataInputStream * in;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_RandomAccessFile__
diff --git a/libjava/java/io/RandomAccessFile.java b/libjava/java/io/RandomAccessFile.java
new file mode 100644
index 000000000..d719a1e3b
--- /dev/null
+++ b/libjava/java/io/RandomAccessFile.java
@@ -0,0 +1,1036 @@
+/* RandomAccessFile.java -- Class supporting random file I/O
+ Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.nio.channels.FileChannel;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * Status: Believe complete and correct to 1.1.
+ */
+
+/**
+ * This class allows reading and writing of files at random locations.
+ * Most Java I/O classes are either pure sequential input or output. This
+ * class fulfills the need to be able to read the bytes of a file in an
+ * arbitrary order. In addition, this class implements the
+ * <code>DataInput</code> and <code>DataOutput</code> interfaces to allow
+ * the reading and writing of Java primitives.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Tom Tromey (tromey@cygnus.com)
+ */
+public class RandomAccessFile implements DataOutput, DataInput, Closeable
+{
+
+ // The underlying file.
+ private FileChannelImpl ch;
+ private FileDescriptor fd;
+ // The corresponding input and output streams.
+ private DataOutputStream out;
+ private DataInputStream in;
+
+
+ /**
+ * This method initializes a new instance of <code>RandomAccessFile</code>
+ * to read from the specified <code>File</code> object with the specified
+ * access mode. The access mode is either "r" for read only access or "rw"
+ * for read-write access.
+ * <p>
+ * Note that a <code>SecurityManager</code> check is made prior to
+ * opening the file to determine whether or not this file is allowed to
+ * be read or written.
+ *
+ * @param file The <code>File</code> object to read and/or write.
+ * @param mode "r" for read only or "rw" for read-write access to the file
+ *
+ * @exception IllegalArgumentException If <code>mode</code> has an
+ * illegal value
+ * @exception SecurityException If the requested access to the file
+ * is not allowed
+ * @exception FileNotFoundException If the file is a directory, or
+ * any other error occurs
+ */
+ public RandomAccessFile (File file, String mode)
+ throws FileNotFoundException
+ {
+ int fdmode;
+ if (mode.equals("r"))
+ fdmode = FileChannelImpl.READ;
+ else if (mode.equals("rw"))
+ fdmode = FileChannelImpl.READ | FileChannelImpl.WRITE;
+ else if (mode.equals("rws"))
+ {
+ fdmode = (FileChannelImpl.READ | FileChannelImpl.WRITE
+ | FileChannelImpl.SYNC);
+ }
+ else if (mode.equals("rwd"))
+ {
+ fdmode = (FileChannelImpl.READ | FileChannelImpl.WRITE
+ | FileChannelImpl.DSYNC);
+ }
+ else
+ throw new IllegalArgumentException ("invalid mode: " + mode);
+
+ final String fileName = file.getPath();
+
+ // The obligatory SecurityManager stuff
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ {
+ s.checkRead(fileName);
+
+ if ((fdmode & FileChannelImpl.WRITE) != 0)
+ s.checkWrite(fileName);
+ }
+
+ ch = FileChannelImpl.create(file, fdmode);
+ fd = new FileDescriptor(ch);
+ if ((fdmode & FileChannelImpl.WRITE) != 0)
+ out = new DataOutputStream (new FileOutputStream (fd));
+ else
+ out = null;
+ in = new DataInputStream (new FileInputStream (fd));
+ }
+
+ /**
+ * This method initializes a new instance of <code>RandomAccessFile</code>
+ * to read from the specified file name with the specified access mode.
+ * The access mode is either "r" for read only access, "rw" for read
+ * write access, "rws" for synchronized read/write access of both
+ * content and metadata, or "rwd" for read/write access
+ * where only content is required to be synchronous.
+ * <p>
+ * Note that a <code>SecurityManager</code> check is made prior to
+ * opening the file to determine whether or not this file is allowed to
+ * be read or written.
+ *
+ * @param fileName The name of the file to read and/or write
+ * @param mode "r", "rw", "rws", or "rwd"
+ *
+ * @exception IllegalArgumentException If <code>mode</code> has an
+ * illegal value
+ * @exception SecurityException If the requested access to the file
+ * is not allowed
+ * @exception FileNotFoundException If the file is a directory or
+ * any other error occurs
+ */
+ public RandomAccessFile (String fileName, String mode)
+ throws FileNotFoundException
+ {
+ this (new File(fileName), mode);
+ }
+
+ /**
+ * This method closes the file and frees up all file related system
+ * resources. Since most operating systems put a limit on how many files
+ * may be opened at any given time, it is a good idea to close all files
+ * when no longer needed to avoid hitting this limit
+ */
+ public void close () throws IOException
+ {
+ ch.close();
+ }
+
+ /**
+ * This method returns a <code>FileDescriptor</code> object that
+ * represents the native file handle for this file.
+ *
+ * @return The <code>FileDescriptor</code> object for this file
+ *
+ * @exception IOException If an error occurs
+ */
+ public final FileDescriptor getFD () throws IOException
+ {
+ synchronized (this)
+ {
+ if (fd == null)
+ fd = new FileDescriptor (ch);
+ return fd;
+ }
+ }
+
+ /**
+ * This method returns the current offset in the file at which the next
+ * read or write will occur
+ *
+ * @return The current file position
+ *
+ * @exception IOException If an error occurs
+ */
+ public long getFilePointer () throws IOException
+ {
+ return ch.position();
+ }
+
+ /**
+ * This method sets the length of the file to the specified length.
+ * If the currently length of the file is longer than the specified
+ * length, then the file is truncated to the specified length (the
+ * file position is set to the end of file in this case). If the
+ * current length of the file is shorter than the specified length,
+ * the file is extended with bytes of an undefined value (the file
+ * position is unchanged in this case).
+ * <p>
+ * The file must be open for write access for this operation to succeed.
+ *
+ * @param newLen The new length of the file
+ *
+ * @exception IOException If an error occurs
+ */
+ public void setLength (long newLen) throws IOException
+ {
+ // FIXME: Extending a file should probably be done by one method call.
+
+ // FileChannel.truncate() can only shrink a file.
+ // To expand it we need to seek forward and write at least one byte.
+ if (newLen < length())
+ ch.truncate (newLen);
+ else if (newLen > length())
+ {
+ long pos = getFilePointer();
+ seek(newLen - 1);
+ write(0);
+ seek(pos);
+ }
+ }
+
+ /**
+ * This method returns the length of the file in bytes
+ *
+ * @return The length of the file
+ *
+ * @exception IOException If an error occurs
+ */
+ public long length () throws IOException
+ {
+ return ch.size();
+ }
+
+ /**
+ * This method reads a single byte of data from the file and returns it
+ * as an integer.
+ *
+ * @return The byte read as an int, or -1 if the end of the file was reached.
+ *
+ * @exception IOException If an error occurs
+ */
+ public int read () throws IOException
+ {
+ return in.read();
+ }
+
+ /**
+ * This method reads bytes from the file into the specified array. The
+ * bytes are stored starting at the beginning of the array and up to
+ * <code>buf.length</code> bytes can be read.
+ *
+ * @param buffer The buffer to read bytes from the file into
+ *
+ * @return The actual number of bytes read or -1 if end of file
+ *
+ * @exception IOException If an error occurs
+ */
+ public int read (byte[] buffer) throws IOException
+ {
+ return in.read (buffer);
+ }
+
+ /**
+ * This methods reads up to <code>len</code> bytes from the file into the
+ * specified array starting at position <code>offset</code> into the array.
+ *
+ * @param buffer The array to read the bytes into
+ * @param offset The index into the array to start storing bytes
+ * @param len The requested number of bytes to read
+ *
+ * @return The actual number of bytes read, or -1 if end of file
+ *
+ * @exception IOException If an error occurs
+ */
+ public int read (byte[] buffer, int offset, int len) throws IOException
+ {
+ return in.read (buffer, offset, len);
+ }
+
+ /**
+ * This method reads a Java boolean value from an input stream. It does
+ * so by reading a single byte of data. If that byte is zero, then the
+ * value returned is <code>false</code> If the byte is non-zero, then
+ * the value returned is <code>true</code>
+ * <p>
+ * This method can read a <code>boolean</code> written by an object
+ * implementing the
+ * <code>writeBoolean()</code> method in the <code>DataOutput</code>
+ * interface.
+ *
+ * @return The <code>boolean</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the
+ * boolean
+ * @exception IOException If any other error occurs
+ */
+ public final boolean readBoolean () throws IOException
+ {
+ return in.readBoolean ();
+ }
+
+ /**
+ * This method reads a Java byte value from an input stream. The value
+ * is in the range of -128 to 127.
+ * <p>
+ * This method can read a <code>byte</code> written by an object
+ * implementing the
+ * <code>writeByte()</code> method in the <code>DataOutput</code> interface.
+ *
+ * @return The <code>byte</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the byte
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput
+ */
+ public final byte readByte () throws IOException
+ {
+ return in.readByte ();
+ }
+
+ /**
+ * This method reads a Java <code>char</code> value from an input stream.
+ * It operates by reading two bytes from the stream and converting them to
+ * a single 16-bit Java <code>char</code> The two bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code> represent
+ * the first
+ * and second byte read from the stream respectively, they will be
+ * transformed to a <code>char</code> in the following manner:
+ * <p>
+ * <code>(char)(((byte1 &amp; 0xFF) &lt;&lt; 8) | (byte2 &amp; 0xFF)</code>
+ * <p>
+ * This method can read a <code>char</code> written by an object
+ * implementing the
+ * <code>writeChar()</code> method in the <code>DataOutput</code> interface.
+ *
+ * @return The <code>char</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the char
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput
+ */
+ public final char readChar () throws IOException
+ {
+ return in.readChar();
+ }
+
+ /**
+ * This method reads a Java double value from an input stream. It operates
+ * by first reading a <code>logn</code> value from the stream by calling the
+ * <code>readLong()</code> method in this interface, then
+ * converts that <code>long</code>
+ * to a <code>double</code> using the <code>longBitsToDouble</code>
+ * method in the class <code>java.lang.Double</code>
+ * <p>
+ * This method can read a <code>double</code> written by an object
+ * implementing the
+ * <code>writeDouble()</code> method in the <code>DataOutput</code>
+ * interface.
+ *
+ * @return The <code>double</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading
+ * the double
+ * @exception IOException If any other error occurs
+ *
+ * @see java.lang.Double
+ * @see DataOutput
+ */
+ public final double readDouble () throws IOException
+ {
+ return in.readDouble ();
+ }
+
+ /**
+ * This method reads a Java float value from an input stream. It operates
+ * by first reading an <code>int</code> value from the stream by calling the
+ * <code>readInt()</code> method in this interface, then converts
+ * that <code>int</code>
+ * to a <code>float</code> using the <code>intBitsToFloat</code> method in
+ * the class <code>java.lang.Float</code>
+ * <p>
+ * This method can read a <code>float</code> written by an object
+ * implementing the
+ * <code>writeFloat()</code> method in the <code>DataOutput</code> interface.
+ *
+ * @return The <code>float</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the float
+ * @exception IOException If any other error occurs
+ *
+ * @see java.lang.Float
+ * @see DataOutput
+ */
+ public final float readFloat () throws IOException
+ {
+ return in.readFloat();
+ }
+
+ /**
+ * This method reads raw bytes into the passed array until the array is
+ * full. Note that this method blocks until the data is available and
+ * throws an exception if there is not enough data left in the stream to
+ * fill the buffer
+ *
+ * @param buffer The buffer into which to read the data
+ *
+ * @exception EOFException If end of file is reached before filling the
+ * buffer
+ * @exception IOException If any other error occurs
+ */
+ public final void readFully (byte[] buffer) throws IOException
+ {
+ in.readFully(buffer);
+ }
+
+ /**
+ * This method reads raw bytes into the passed array <code>buf</code>
+ * starting
+ * <code>offset</code> bytes into the buffer. The number of bytes read
+ * will be
+ * exactly <code>len</code> Note that this method blocks until the data is
+ * available and throws an exception if there is not enough data left in
+ * the stream to read <code>len</code> bytes.
+ *
+ * @param buffer The buffer into which to read the data
+ * @param offset The offset into the buffer to start storing data
+ * @param count The number of bytes to read into the buffer
+ *
+ * @exception EOFException If end of file is reached before filling
+ * the buffer
+ * @exception IOException If any other error occurs
+ */
+ public final void readFully (byte[] buffer, int offset, int count)
+ throws IOException
+ {
+ in.readFully (buffer, offset, count);
+ }
+
+ /**
+ * This method reads a Java <code>int</code> value from an input stream
+ * It operates by reading four bytes from the stream and converting them to
+ * a single Java <code>int</code> The bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> through <code>byte4</code>
+ * represent the first
+ * four bytes read from the stream, they will be
+ * transformed to an <code>int</code> in the following manner:
+ * <p>
+ * <code>(int)(((byte1 &amp; 0xFF) &lt;&lt; 24) + ((byte2 &amp; 0xFF) &lt;&lt; 16) +
+ * ((byte3 &amp; 0xFF) &lt;&lt; 8) + (byte4 &amp; 0xFF)))</code>
+ * <p>
+ * The value returned is in the range of 0 to 65535.
+ * <p>
+ * This method can read an <code>int</code> written by an object
+ * implementing the
+ * <code>writeInt()</code> method in the <code>DataOutput</code> interface.
+ *
+ * @return The <code>int</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the int
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput
+ */
+ public final int readInt () throws IOException
+ {
+ return in.readInt();
+ }
+
+ /**
+ * This method reads the next line of text data from an input stream.
+ * It operates by reading bytes and converting those bytes to
+ * <code>char</code>
+ * values by treating the byte read as the low eight bits of the
+ * <code>char</code>
+ * and using <code>0</code> as the high eight bits. Because of this, it does
+ * not support the full 16-bit Unicode character set.
+ * <p>
+ * The reading of bytes ends when either the end of file or a line terminator
+ * is encountered. The bytes read are then returned as a <code>String</code>
+ * A line terminator is a byte sequence consisting of either
+ * <code>\r</code> <code>\n</code> or <code>\r\n</code> These
+ * termination charaters are
+ * discarded and are not returned as part of the string.
+ * <p>
+ * This method can read data that was written by an object implementing the
+ * <code>writeLine()</code> method in <code>DataOutput</code>
+ *
+ * @return The line read as a <code>String</code>
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see DataOutput
+ */
+ public final String readLine () throws IOException
+ {
+ return in.readLine ();
+ }
+
+ /**
+ * This method reads a Java long value from an input stream
+ * It operates by reading eight bytes from the stream and converting them to
+ * a single Java <code>long</code> The bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> through <code>byte8</code>
+ * represent the first
+ * eight bytes read from the stream, they will be
+ * transformed to an <code>long</code> in the following manner:
+ * <p>
+ * <code>
+ * (long)((((long)byte1 &amp; 0xFF) &lt;&lt; 56) + (((long)byte2 &amp; 0xFF) &lt;&lt; 48) +
+ * (((long)byte3 &amp; 0xFF) &lt;&lt; 40) + (((long)byte4 &amp; 0xFF) &lt;&lt; 32) +
+ * (((long)byte5 &amp; 0xFF) &lt;&lt; 24) + (((long)byte6 &amp; 0xFF) &lt;&lt; 16) +
+ * (((long)byte7 &amp; 0xFF) &lt;&lt; 8) + ((long)byte9 &amp; 0xFF)))</code>
+ * <p>
+ * The value returned is in the range of 0 to 65535.
+ * <p>
+ * This method can read an <code>long</code> written by an object
+ * implementing the
+ * <code>writeLong()</code> method in the <code>DataOutput</code> interface.
+ *
+ * @return The <code>long</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the long
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput
+ */
+ public final long readLong () throws IOException
+ {
+ return in.readLong();
+ }
+
+ /**
+ * This method reads a signed 16-bit value into a Java in from the stream.
+ * It operates by reading two bytes from the stream and converting them to
+ * a single 16-bit Java <code>short</code> The two bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code>
+ * represent the first
+ * and second byte read from the stream respectively, they will be
+ * transformed to a <code>short</code> in the following manner:
+ * <p>
+ * <code>(short)(((byte1 &amp; 0xFF) &lt;&lt; 8) | (byte2 &amp; 0xFF)</code>
+ * <p>
+ * The value returned is in the range of -32768 to 32767.
+ * <p>
+ * This method can read a <code>short</code> written by an object
+ * implementing the
+ * <code>writeShort()</code> method in the <code>DataOutput</code> interface.
+ *
+ * @return The <code>short</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the value
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput
+ */
+ public final short readShort () throws IOException
+ {
+ return in.readShort();
+ }
+
+ /**
+ * This method reads 8 unsigned bits into a Java <code>int</code> value
+ * from the
+ * stream. The value returned is in the range of 0 to 255.
+ * <p>
+ * This method can read an unsigned byte written by an object implementing
+ * the <code>writeUnsignedByte()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The unsigned bytes value read as a Java <code>int</code>
+ *
+ * @exception EOFException If end of file is reached before reading the value
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput
+ */
+ public final int readUnsignedByte () throws IOException
+ {
+ return in.readUnsignedByte();
+ }
+
+ /**
+ * This method reads 16 unsigned bits into a Java int value from the stream.
+ * It operates by reading two bytes from the stream and converting them to
+ * a single Java <code>int</code> The two bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code>
+ * represent the first
+ * and second byte read from the stream respectively, they will be
+ * transformed to an <code>int</code> in the following manner:
+ * <p>
+ * <code>(int)(((byte1 &amp; 0xFF) &lt;&lt; 8) + (byte2 &amp; 0xFF))</code>
+ * <p>
+ * The value returned is in the range of 0 to 65535.
+ * <p>
+ * This method can read an unsigned short written by an object implementing
+ * the <code>writeUnsignedShort()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The unsigned short value read as a Java <code>int</code>
+ *
+ * @exception EOFException If end of file is reached before reading the value
+ * @exception IOException If any other error occurs
+ */
+ public final int readUnsignedShort () throws IOException
+ {
+ return in.readUnsignedShort();
+ }
+
+ /**
+ * This method reads a <code>String</code> from an input stream that
+ * is encoded in
+ * a modified UTF-8 format. This format has a leading two byte sequence
+ * that contains the remaining number of bytes to read. This two byte
+ * sequence is read using the <code>readUnsignedShort()</code> method of this
+ * interface.
+ * <p>
+ * After the number of remaining bytes have been determined, these bytes
+ * are read an transformed into <code>char</code> values.
+ * These <code>char</code> values
+ * are encoded in the stream using either a one, two, or three byte format.
+ * The particular format in use can be determined by examining the first
+ * byte read.
+ * <p>
+ * If the first byte has a high order bit of 0 then
+ * that character consists on only one byte. This character value consists
+ * of seven bits that are at positions 0 through 6 of the byte. As an
+ * example, if <code>byte1</code> is the byte read from the stream, it would
+ * be converted to a <code>char</code> like so:
+ * <p>
+ * <code>(char)byte1</code>
+ * <p>
+ * If the first byte has <code>110</code> as its high order bits, then the
+ * character consists of two bytes. The bits that make up the character
+ * value are in positions 0 through 4 of the first byte and bit positions
+ * 0 through 5 of the second byte. (The second byte should have
+ * 10 as its high order bits). These values are in most significant
+ * byte first (i.e., "big endian") order.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code>
+ * are the first two bytes
+ * read respectively, and the high order bits of them match the patterns
+ * which indicate a two byte character encoding, then they would be
+ * converted to a Java <code>char</code> like so:
+ * <p>
+ * <code>(char)(((byte1 & 0x1F) << 6) | (byte2 & 0x3F))</code>
+ * <p>
+ * If the first byte has a <code>1110</code> as its high order bits, then the
+ * character consists of three bytes. The bits that make up the character
+ * value are in positions 0 through 3 of the first byte and bit positions
+ * 0 through 5 of the other two bytes. (The second and third bytes should
+ * have <code>10</code> as their high order bits). These values are in most
+ * significant byte first (i.e., "big endian") order.
+ * <p>
+ * As an example, if <code>byte1</code> <code>byte2</code>
+ * and <code>byte3</code> are the
+ * three bytes read, and the high order bits of them match the patterns
+ * which indicate a three byte character encoding, then they would be
+ * converted to a Java <code>char</code> like so:
+ * <p>
+ * <code>(char)(((byte1 & 0x0F) << 12) | ((byte2 & 0x3F) << 6) |
+ * (byte3 & 0x3F))</code>
+ * <p>
+ * Note that all characters are encoded in the method that requires the
+ * fewest number of bytes with the exception of the character with the
+ * value of <code>&#92;u0000</code> which is encoded as two bytes. This is
+ * a modification of the UTF standard used to prevent C language style
+ * <code>NUL</code> values from appearing in the byte stream.
+ * <p>
+ * This method can read data that was written by an object implementing the
+ * <code>writeUTF()</code> method in <code>DataOutput</code>
+ *
+ * @return The <code>String</code> read
+ *
+ * @exception EOFException If end of file is reached before reading the
+ * String
+ * @exception UTFDataFormatException If the data is not in UTF-8 format
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput
+ */
+ public final String readUTF () throws IOException
+ {
+ return in.readUTF();
+ }
+
+ /**
+ * This method sets the current file position to the specified offset
+ * from the beginning of the file. Note that some operating systems will
+ * allow the file pointer to be set past the current end of the file.
+ *
+ * @param pos The offset from the beginning of the file at which to set
+ * the file pointer
+ *
+ * @exception IOException If an error occurs
+ */
+ public void seek (long pos) throws IOException
+ {
+ ch.position(pos);
+ }
+
+ /**
+ * This method attempts to skip and discard the specified number of bytes
+ * in the input stream. It may actually skip fewer bytes than requested.
+ * The actual number of bytes skipped is returned. This method will not
+ * skip any bytes if passed a negative number of bytes to skip.
+ *
+ * @param numBytes The requested number of bytes to skip.
+ *
+ * @return The number of bytes actually skipped.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public int skipBytes (int numBytes) throws IOException
+ {
+ if (numBytes < 0)
+ throw new IllegalArgumentException ("Can't skip negative bytes: " +
+ numBytes);
+
+ if (numBytes == 0)
+ return 0;
+
+ long oldPos = ch.position();
+ long newPos = oldPos + numBytes;
+ long size = ch.size();
+ if (newPos > size)
+ newPos = size;
+ ch.position(newPos);
+ return (int) (ch.position() - oldPos);
+ }
+
+ /**
+ * This method writes a single byte of data to the file. The file must
+ * be open for read-write in order for this operation to succeed.
+ *
+ * @param oneByte The byte of data to write, passed as an int.
+ *
+ * @exception IOException If an error occurs
+ */
+ public void write (int oneByte) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.write(oneByte);
+ }
+
+ /**
+ * This method writes all the bytes in the specified array to the file.
+ * The file must be open read-write in order for this operation to succeed.
+ *
+ * @param buffer The array of bytes to write to the file
+ */
+ public void write (byte[] buffer) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.write(buffer);
+ }
+
+ /**
+ * This method writes <code>len</code> bytes to the file from the specified
+ * array starting at index <code>offset</code> into the array.
+ *
+ * @param buffer The array of bytes to write to the file
+ * @param offset The index into the array to start writing file
+ * @param len The number of bytes to write
+ *
+ * @exception IOException If an error occurs
+ */
+ public void write (byte[] buffer, int offset, int len) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.write (buffer, offset, len);
+ }
+
+ /**
+ * This method writes a Java <code>boolean</code> to the underlying output
+ * stream. For a value of <code>true</code>, 1 is written to the stream.
+ * For a value of <code>false</code>, 0 is written.
+ *
+ * @param val The <code>boolean</code> value to write to the stream
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void writeBoolean (boolean val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeBoolean(val);
+ }
+
+ /**
+ * This method writes a Java <code>byte</code> value to the underlying
+ * output stream.
+ *
+ * @param val The <code>byte</code> to write to the stream, passed
+ * as an <code>int</code>.
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void writeByte (int val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeByte(val);
+ }
+
+ /**
+ * This method writes a Java <code>short</code> to the stream, high byte
+ * first. This method requires two bytes to encode the value.
+ *
+ * @param val The <code>short</code> value to write to the stream,
+ * passed as an <code>int</code>.
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void writeShort (int val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeShort(val);
+ }
+
+ /**
+ * This method writes a single <code>char</code> value to the stream,
+ * high byte first.
+ *
+ * @param val The <code>char</code> value to write, passed as
+ * an <code>int</code>.
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void writeChar (int val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeChar(val);
+ }
+
+ /**
+ * This method writes a Java <code>int</code> to the stream, high bytes
+ * first. This method requires four bytes to encode the value.
+ *
+ * @param val The <code>int</code> value to write to the stream.
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void writeInt (int val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeInt(val);
+ }
+
+ /**
+ * This method writes a Java <code>long</code> to the stream, high bytes
+ * first. This method requires eight bytes to encode the value.
+ *
+ * @param val The <code>long</code> value to write to the stream.
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void writeLong (long val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeLong(val);
+ }
+
+ /**
+ * This method writes a Java <code>float</code> value to the stream. This
+ * value is written by first calling the method
+ * <code>Float.floatToIntBits</code>
+ * to retrieve an <code>int</code> representing the floating point number,
+ * then writing this <code>int</code> value to the stream exactly the same
+ * as the <code>writeInt()</code> method does.
+ *
+ * @param val The floating point number to write to the stream.
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see #writeInt(int)
+ */
+ public final void writeFloat (float val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeFloat(val);
+ }
+
+ /**
+ * This method writes a Java <code>double</code> value to the stream. This
+ * value is written by first calling the method
+ * <code>Double.doubleToLongBits</code>
+ * to retrieve an <code>long</code> representing the floating point number,
+ * then writing this <code>long</code> value to the stream exactly the same
+ * as the <code>writeLong()</code> method does.
+ *
+ * @param val The double precision floating point number to write to the
+ * stream.
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see #writeLong(long)
+ */
+ public final void writeDouble (double val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeDouble(val);
+ }
+
+ /**
+ * This method writes all the bytes in a <code>String</code> out to the
+ * stream. One byte is written for each character in the <code>String</code>.
+ * The high eight bits of each character are discarded.
+ *
+ * @param val The <code>String</code> to write to the stream
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void writeBytes (String val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeBytes(val);
+ }
+
+ /**
+ * This method writes all the characters in a <code>String</code> to the
+ * stream. There will be two bytes for each character value. The high
+ * byte of the character will be written first.
+ *
+ * @param val The <code>String</code> to write to the stream.
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void writeChars (String val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeChars(val);
+ }
+
+ /**
+ * This method writes a Java <code>String</code> to the stream in a modified
+ * UTF-8 format. First, two bytes are written to the stream indicating the
+ * number of bytes to follow. Note that this is the number of bytes in the
+ * encoded <code>String</code> not the <code>String</code> length. Next
+ * come the encoded characters. Each character in the <code>String</code>
+ * is encoded as either one, two or three bytes. For characters in the
+ * range of <code>&#92;u0001</code> to <code>&#92;u007F</code>,
+ * one byte is used. The character
+ * value goes into bits 0-7 and bit eight is 0. For characters in the range
+ * of <code>&#92;u0080</code> to <code>&#92;u007FF</code>, two
+ * bytes are used. Bits
+ * 6-10 of the character value are encoded bits 0-4 of the first byte, with
+ * the high bytes having a value of "110". Bits 0-5 of the character value
+ * are stored in bits 0-5 of the second byte, with the high bits set to
+ * "10". This type of encoding is also done for the null character
+ * <code>&#92;u0000</code>. This eliminates any C style NUL character values
+ * in the output. All remaining characters are stored as three bytes.
+ * Bits 12-15 of the character value are stored in bits 0-3 of the first
+ * byte. The high bits of the first bytes are set to "1110". Bits 6-11
+ * of the character value are stored in bits 0-5 of the second byte. The
+ * high bits of the second byte are set to "10". And bits 0-5 of the
+ * character value are stored in bits 0-5 of byte three, with the high bits
+ * of that byte set to "10".
+ *
+ * @param val The <code>String</code> to write to the output in UTF format
+ *
+ * @exception IOException If an error occurs
+ */
+ public final void writeUTF (String val) throws IOException
+ {
+ if (out == null)
+ throw new IOException("Bad file descriptor");
+
+ out.writeUTF(val);
+ }
+
+ /**
+ * This method creates a java.nio.channels.FileChannel.
+ * Nio does not allow one to create a file channel directly.
+ * A file channel must be created by first creating an instance of
+ * Input/Output/RandomAccessFile and invoking the getChannel() method on it.
+ */
+ public final synchronized FileChannel getChannel ()
+ {
+ return ch;
+ }
+}
diff --git a/libjava/java/io/Reader.h b/libjava/java/io/Reader.h
new file mode 100644
index 000000000..678bc9181
--- /dev/null
+++ b/libjava/java/io/Reader.h
@@ -0,0 +1,46 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_Reader__
+#define __java_io_Reader__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ class CharBuffer;
+ }
+ }
+}
+
+class java::io::Reader : public ::java::lang::Object
+{
+
+public: // actually protected
+ Reader();
+ Reader(::java::lang::Object *);
+public:
+ virtual jint read(JArray< jchar > *, jint, jint) = 0;
+ virtual jint read(JArray< jchar > *);
+ virtual jint read();
+ virtual jint read(::java::nio::CharBuffer *);
+ virtual void close() = 0;
+ virtual jboolean markSupported();
+ virtual void mark(jint);
+ virtual void reset();
+ virtual jboolean ready();
+ virtual jlong skip(jlong);
+public: // actually protected
+ ::java::lang::Object * __attribute__((aligned(__alignof__( ::java::lang::Object)))) lock;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_Reader__
diff --git a/libjava/java/io/SequenceInputStream.h b/libjava/java/io/SequenceInputStream.h
new file mode 100644
index 000000000..f5baa7d10
--- /dev/null
+++ b/libjava/java/io/SequenceInputStream.h
@@ -0,0 +1,32 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_SequenceInputStream__
+#define __java_io_SequenceInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::SequenceInputStream : public ::java::io::InputStream
+{
+
+public:
+ SequenceInputStream(::java::util::Enumeration *);
+ SequenceInputStream(::java::io::InputStream *, ::java::io::InputStream *);
+ virtual jint available();
+ virtual void close();
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+private:
+ ::java::io::InputStream * getNextStream();
+ ::java::io::InputStream * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) in;
+ ::java::io::InputStream * in2;
+ ::java::util::Enumeration * e;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_SequenceInputStream__
diff --git a/libjava/java/io/Serializable.h b/libjava/java/io/Serializable.h
new file mode 100644
index 000000000..12c36e55c
--- /dev/null
+++ b/libjava/java/io/Serializable.h
@@ -0,0 +1,18 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_Serializable__
+#define __java_io_Serializable__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::Serializable : public ::java::lang::Object
+{
+
+public:
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __java_io_Serializable__
diff --git a/libjava/java/io/SerializablePermission.h b/libjava/java/io/SerializablePermission.h
new file mode 100644
index 000000000..04c3dcee4
--- /dev/null
+++ b/libjava/java/io/SerializablePermission.h
@@ -0,0 +1,27 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_SerializablePermission__
+#define __java_io_SerializablePermission__
+
+#pragma interface
+
+#include <java/security/BasicPermission.h>
+#include <gcj/array.h>
+
+
+class java::io::SerializablePermission : public ::java::security::BasicPermission
+{
+
+public:
+ SerializablePermission(::java::lang::String *);
+ SerializablePermission(::java::lang::String *, ::java::lang::String *);
+public: // actually package-private
+ static const jlong serialVersionUID = 8537212141160296410LL;
+private:
+ static JArray< ::java::lang::String * > * legal_names;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_SerializablePermission__
diff --git a/libjava/java/io/StreamCorruptedException.h b/libjava/java/io/StreamCorruptedException.h
new file mode 100644
index 000000000..79b0d02a9
--- /dev/null
+++ b/libjava/java/io/StreamCorruptedException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_StreamCorruptedException__
+#define __java_io_StreamCorruptedException__
+
+#pragma interface
+
+#include <java/io/ObjectStreamException.h>
+
+class java::io::StreamCorruptedException : public ::java::io::ObjectStreamException
+{
+
+public:
+ StreamCorruptedException();
+ StreamCorruptedException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = 8983558202217591746LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_StreamCorruptedException__
diff --git a/libjava/java/io/StreamTokenizer.h b/libjava/java/io/StreamTokenizer.h
new file mode 100644
index 000000000..ad9496cd4
--- /dev/null
+++ b/libjava/java/io/StreamTokenizer.h
@@ -0,0 +1,72 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_StreamTokenizer__
+#define __java_io_StreamTokenizer__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+
+class java::io::StreamTokenizer : public ::java::lang::Object
+{
+
+public:
+ StreamTokenizer(::java::io::InputStream *);
+ StreamTokenizer(::java::io::Reader *);
+ virtual void commentChar(jint);
+ virtual void eolIsSignificant(jboolean);
+ virtual jint lineno();
+ virtual void lowerCaseMode(jboolean);
+private:
+ jboolean isWhitespace(jint);
+ jboolean isAlphabetic(jint);
+ jboolean isNumeric(jint);
+ jboolean isQuote(jint);
+ jboolean isComment(jint);
+public:
+ virtual jint nextToken();
+private:
+ void resetChar(jint);
+public:
+ virtual void ordinaryChar(jint);
+ virtual void ordinaryChars(jint, jint);
+ virtual void parseNumbers();
+ virtual void pushBack();
+ virtual void quoteChar(jint);
+ virtual void resetSyntax();
+ virtual void slashSlashComments(jboolean);
+ virtual void slashStarComments(jboolean);
+ virtual ::java::lang::String * toString();
+ virtual void whitespaceChars(jint, jint);
+ virtual void wordChars(jint, jint);
+ static const jint TT_EOF = -1;
+ static const jint TT_EOL = 10;
+ static const jint TT_NUMBER = -2;
+ static const jint TT_WORD = -3;
+private:
+ static const jint TT_NONE = -4;
+public:
+ jint __attribute__((aligned(__alignof__( ::java::lang::Object)))) ttype;
+ ::java::lang::String * sval;
+ jdouble nval;
+private:
+ jboolean eolSignificant;
+ jboolean lowerCase;
+ jboolean slashSlash;
+ jboolean slashStar;
+ JArray< jboolean > * whitespace;
+ JArray< jboolean > * alphabetic;
+ JArray< jboolean > * numeric;
+ JArray< jboolean > * quote;
+ JArray< jboolean > * comment;
+ ::java::io::PushbackReader * in;
+ jboolean pushedBack;
+ jint lineNumber;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_StreamTokenizer__
diff --git a/libjava/java/io/StringBufferInputStream.h b/libjava/java/io/StringBufferInputStream.h
new file mode 100644
index 000000000..077bc4d28
--- /dev/null
+++ b/libjava/java/io/StringBufferInputStream.h
@@ -0,0 +1,31 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_StringBufferInputStream__
+#define __java_io_StringBufferInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+
+class java::io::StringBufferInputStream : public ::java::io::InputStream
+{
+
+public:
+ StringBufferInputStream(::java::lang::String *);
+ virtual jint available();
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual void reset();
+ virtual jlong skip(jlong);
+public: // actually protected
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) buffer;
+ jint pos;
+ jint count;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_StringBufferInputStream__
diff --git a/libjava/java/io/StringReader.h b/libjava/java/io/StringReader.h
new file mode 100644
index 000000000..57a2d3f80
--- /dev/null
+++ b/libjava/java/io/StringReader.h
@@ -0,0 +1,35 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_StringReader__
+#define __java_io_StringReader__
+
+#pragma interface
+
+#include <java/io/Reader.h>
+#include <gcj/array.h>
+
+
+class java::io::StringReader : public ::java::io::Reader
+{
+
+public:
+ StringReader(::java::lang::String *);
+ virtual void close();
+ virtual void mark(jint);
+ virtual jboolean markSupported();
+ virtual jint read();
+ virtual jint read(JArray< jchar > *, jint, jint);
+ virtual jboolean ready();
+ virtual void reset();
+ virtual jlong skip(jlong);
+private:
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::io::Reader)))) buf;
+ jint pos;
+ jint markedPos;
+ jint count;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_StringReader__
diff --git a/libjava/java/io/StringWriter.h b/libjava/java/io/StringWriter.h
new file mode 100644
index 000000000..c2933e7af
--- /dev/null
+++ b/libjava/java/io/StringWriter.h
@@ -0,0 +1,43 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_StringWriter__
+#define __java_io_StringWriter__
+
+#pragma interface
+
+#include <java/io/Writer.h>
+#include <gcj/array.h>
+
+
+class java::io::StringWriter : public ::java::io::Writer
+{
+
+public:
+ virtual void close();
+ virtual void flush();
+ virtual ::java::lang::StringBuffer * getBuffer();
+ StringWriter();
+ StringWriter(jint);
+ virtual ::java::lang::String * toString();
+ virtual void write(jint);
+ virtual void write(JArray< jchar > *, jint, jint);
+ virtual void write(::java::lang::String *);
+ virtual void write(::java::lang::String *, jint, jint);
+ virtual ::java::io::StringWriter * StringWriter$append(jchar);
+ virtual ::java::io::StringWriter * StringWriter$append(::java::lang::CharSequence *);
+ virtual ::java::io::StringWriter * StringWriter$append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::io::Writer * Writer$append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *);
+ virtual ::java::io::Writer * Writer$append(::java::lang::CharSequence *);
+ virtual ::java::lang::Appendable * append(jchar);
+ virtual ::java::io::Writer * Writer$append(jchar);
+private:
+ static const jint DEFAULT_BUFFER_SIZE = 16;
+ ::java::lang::StringBuffer * __attribute__((aligned(__alignof__( ::java::io::Writer)))) buffer;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_StringWriter__
diff --git a/libjava/java/io/SyncFailedException.h b/libjava/java/io/SyncFailedException.h
new file mode 100644
index 000000000..1088ca2dd
--- /dev/null
+++ b/libjava/java/io/SyncFailedException.h
@@ -0,0 +1,22 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_SyncFailedException__
+#define __java_io_SyncFailedException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+
+class java::io::SyncFailedException : public ::java::io::IOException
+{
+
+public:
+ SyncFailedException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = -2353342684412443330LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_SyncFailedException__
diff --git a/libjava/java/io/UTFDataFormatException.h b/libjava/java/io/UTFDataFormatException.h
new file mode 100644
index 000000000..48f8cf7a6
--- /dev/null
+++ b/libjava/java/io/UTFDataFormatException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_UTFDataFormatException__
+#define __java_io_UTFDataFormatException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+
+class java::io::UTFDataFormatException : public ::java::io::IOException
+{
+
+public:
+ UTFDataFormatException();
+ UTFDataFormatException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = 420743449228280612LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_UTFDataFormatException__
diff --git a/libjava/java/io/UnsupportedEncodingException.h b/libjava/java/io/UnsupportedEncodingException.h
new file mode 100644
index 000000000..6291af255
--- /dev/null
+++ b/libjava/java/io/UnsupportedEncodingException.h
@@ -0,0 +1,23 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_UnsupportedEncodingException__
+#define __java_io_UnsupportedEncodingException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+
+class java::io::UnsupportedEncodingException : public ::java::io::IOException
+{
+
+public:
+ UnsupportedEncodingException();
+ UnsupportedEncodingException(::java::lang::String *);
+private:
+ static const jlong serialVersionUID = -4274276298326136670LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_UnsupportedEncodingException__
diff --git a/libjava/java/io/VMObjectInputStream.h b/libjava/java/io/VMObjectInputStream.h
new file mode 100644
index 000000000..307dd551f
--- /dev/null
+++ b/libjava/java/io/VMObjectInputStream.h
@@ -0,0 +1,21 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_VMObjectInputStream__
+#define __java_io_VMObjectInputStream__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::VMObjectInputStream : public ::java::lang::Object
+{
+
+public: // actually package-private
+ VMObjectInputStream();
+ static ::java::lang::Object * allocateObject(::java::lang::Class *, ::java::lang::Class *, ::java::lang::reflect::Constructor *);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_VMObjectInputStream__
diff --git a/libjava/java/io/VMObjectInputStream.java b/libjava/java/io/VMObjectInputStream.java
new file mode 100644
index 000000000..77bdf7170
--- /dev/null
+++ b/libjava/java/io/VMObjectInputStream.java
@@ -0,0 +1,56 @@
+/* ObjectInputStream.java -- Class used to read serialized objects
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import gnu.classpath.Configuration;
+import java.lang.reflect.Constructor;
+
+final class VMObjectInputStream
+{
+ /**
+ * Allocates a new Object of type clazz but without running the
+ * default constructor on it. It then calls the given constructor on
+ * it. The given constructor method comes from the constr_clazz
+ * which is a super class of the given clazz.
+ */
+ static native Object allocateObject(Class clazz, Class constr_clazz,
+ Constructor constructor)
+ throws InstantiationException;
+}
diff --git a/libjava/java/io/VMObjectStreamClass.h b/libjava/java/io/VMObjectStreamClass.h
new file mode 100644
index 000000000..5f2ef2cb0
--- /dev/null
+++ b/libjava/java/io/VMObjectStreamClass.h
@@ -0,0 +1,30 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_VMObjectStreamClass__
+#define __java_io_VMObjectStreamClass__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+
+class java::io::VMObjectStreamClass : public ::java::lang::Object
+{
+
+public: // actually package-private
+ VMObjectStreamClass();
+ static jboolean hasClassInitializer(::java::lang::Class *);
+ static void setDoubleNative(::java::lang::reflect::Field *, ::java::lang::Object *, jdouble);
+ static void setFloatNative(::java::lang::reflect::Field *, ::java::lang::Object *, jfloat);
+ static void setLongNative(::java::lang::reflect::Field *, ::java::lang::Object *, jlong);
+ static void setIntNative(::java::lang::reflect::Field *, ::java::lang::Object *, jint);
+ static void setShortNative(::java::lang::reflect::Field *, ::java::lang::Object *, jshort);
+ static void setCharNative(::java::lang::reflect::Field *, ::java::lang::Object *, jchar);
+ static void setByteNative(::java::lang::reflect::Field *, ::java::lang::Object *, jbyte);
+ static void setBooleanNative(::java::lang::reflect::Field *, ::java::lang::Object *, jboolean);
+ static void setObjectNative(::java::lang::reflect::Field *, ::java::lang::Object *, ::java::lang::Object *);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_VMObjectStreamClass__
diff --git a/libjava/java/io/VMObjectStreamClass.java b/libjava/java/io/VMObjectStreamClass.java
new file mode 100644
index 000000000..3900855ab
--- /dev/null
+++ b/libjava/java/io/VMObjectStreamClass.java
@@ -0,0 +1,140 @@
+/* VMObjectStreamClass.java -- VM helper functions for ObjectStreamClass
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import java.lang.reflect.Field;
+
+final class VMObjectStreamClass
+{
+ /**
+ * Returns true if CLAZZ has a static class initializer
+ * (a.k.a. <clinit>).
+ */
+ static native boolean hasClassInitializer (Class clazz);
+
+ /**
+ * Sets the value of the specified "double" field, allowing final values
+ * to be assigned.
+ *
+ * @param field Field to set the value.
+ * @param obj Instance which will have its field set.
+ * @param val Value to put in the field.
+ */
+ static native void setDoubleNative(Field field, Object obj, double val);
+
+ /**
+ * Sets the value of the specified "float" field, allowing final values
+ * to be assigned.
+ *
+ * @param field Field to set the value.
+ * @param obj Instance which will have its field set.
+ * @param val Value to put in the field.
+ */
+ static native void setFloatNative(Field field, Object obj, float val);
+
+ /**
+ * Sets the value of the specified "long" field, allowing final values
+ * to be assigned.
+ *
+ * @param field Field to set the value.
+ * @param obj Instance which will have its field set.
+ * @param val Value to put in the field.
+ */
+ static native void setLongNative(Field field, Object obj, long val);
+
+ /**
+ * Sets the value of the specified "int" field, allowing final values
+ * to be assigned.
+ *
+ * @param field Field to set the value.
+ * @param obj Instance which will have its field set.
+ * @param val Value to put in the field.
+ */
+ static native void setIntNative(Field field, Object obj, int val);
+
+ /**
+ * Sets the value of the specified "short" field, allowing final values
+ * to be assigned.
+ *
+ * @param field Field to set the value.
+ * @param obj Instance which will have its field set.
+ * @param val Value to put in the field.
+ */
+ static native void setShortNative(Field field, Object obj, short val);
+
+ /**
+ * Sets the value of the specified "char" field, allowing final values
+ * to be assigned.
+ *
+ * @param field Field to set the value.
+ * @param obj Instance which will have its field set.
+ * @param val Value to put in the field.
+ */
+ static native void setCharNative(Field field, Object obj, char val);
+
+ /**
+ * Sets the value of the specified "byte" field, allowing final values
+ * to be assigned.
+ *
+ * @param field Field to set the value.
+ * @param obj Instance which will have its field set.
+ * @param val Value to put in the field.
+ */
+ static native void setByteNative(Field field, Object obj, byte val);
+
+ /**
+ * Sets the value of the specified "boolean" field, allowing final values
+ * to be assigned.
+ *
+ * @param field Field to set the value.
+ * @param obj Instance which will have its field set.
+ * @param val Value to put in the field.
+ */
+ static native void setBooleanNative(Field field, Object obj, boolean val);
+
+ /**
+ * Sets the value of the specified object field, allowing final values
+ * to be assigned.
+ *
+ * @param field Field to set the value.
+ * @param obj Instance which will have its field set.
+ * @param val Value to put in the field.
+ */
+ static native void setObjectNative(Field field, Object obj, Object val);
+}
diff --git a/libjava/java/io/WriteAbortedException.h b/libjava/java/io/WriteAbortedException.h
new file mode 100644
index 000000000..712c04d0f
--- /dev/null
+++ b/libjava/java/io/WriteAbortedException.h
@@ -0,0 +1,25 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_WriteAbortedException__
+#define __java_io_WriteAbortedException__
+
+#pragma interface
+
+#include <java/io/ObjectStreamException.h>
+
+class java::io::WriteAbortedException : public ::java::io::ObjectStreamException
+{
+
+public:
+ WriteAbortedException(::java::lang::String *, ::java::lang::Exception *);
+ virtual ::java::lang::String * getMessage();
+ virtual ::java::lang::Throwable * getCause();
+private:
+ static const jlong serialVersionUID = -3326426625597282442LL;
+public:
+ ::java::lang::Exception * __attribute__((aligned(__alignof__( ::java::io::ObjectStreamException)))) detail;
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_WriteAbortedException__
diff --git a/libjava/java/io/Writer.h b/libjava/java/io/Writer.h
new file mode 100644
index 000000000..148501ac6
--- /dev/null
+++ b/libjava/java/io/Writer.h
@@ -0,0 +1,39 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_io_Writer__
+#define __java_io_Writer__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+
+class java::io::Writer : public ::java::lang::Object
+{
+
+public: // actually protected
+ Writer();
+ Writer(::java::lang::Object *);
+public:
+ virtual void flush() = 0;
+ virtual void close() = 0;
+ virtual void write(jint);
+ virtual void write(JArray< jchar > *);
+ virtual void write(JArray< jchar > *, jint, jint) = 0;
+ virtual void write(::java::lang::String *);
+ virtual void write(::java::lang::String *, jint, jint);
+ virtual ::java::io::Writer * Writer$append(jchar);
+ virtual ::java::io::Writer * Writer$append(::java::lang::CharSequence *);
+ virtual ::java::io::Writer * Writer$append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *, jint, jint);
+ virtual ::java::lang::Appendable * append(::java::lang::CharSequence *);
+ virtual ::java::lang::Appendable * append(jchar);
+public: // actually protected
+ ::java::lang::Object * __attribute__((aligned(__alignof__( ::java::lang::Object)))) lock;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_io_Writer__
diff --git a/libjava/java/io/natFilePosix.cc b/libjava/java/io/natFilePosix.cc
new file mode 100644
index 000000000..5b6ec8458
--- /dev/null
+++ b/libjava/java/io/natFilePosix.cc
@@ -0,0 +1,509 @@
+// natFile.cc - Native part of File class for POSIX.
+
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2008
+ Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+#include <string.h>
+#include <utime.h>
+
+#include <gcj/cni.h>
+#include <jvm.h>
+#include <java/io/File.h>
+#include <java/io/IOException.h>
+#include <java/util/ArrayList.h>
+#include <java/lang/String.h>
+#include <java/io/FilenameFilter.h>
+#include <java/io/FileFilter.h>
+#include <java/lang/System.h>
+
+jboolean
+java::io::File::_access (jint query)
+{
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+ JvAssert (query == READ || query == WRITE || query == EXISTS
+ || query == EXEC);
+#ifdef HAVE_ACCESS
+ int mode;
+ if (query == READ)
+ mode = R_OK;
+ else if (query == WRITE)
+ mode = W_OK;
+ else if (query == EXISTS)
+ mode = F_OK;
+ else
+ mode = X_OK;
+ return ::access (buf, mode) == 0;
+#else
+ return false;
+#endif
+}
+
+jboolean
+java::io::File::_stat (jint query)
+{
+ if (query == ISHIDDEN)
+ return getName()->charAt(0) == '.';
+
+#ifdef HAVE_STAT
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+
+ struct stat sb;
+ if (::stat (buf, &sb))
+ return false;
+
+ JvAssert (query == DIRECTORY || query == ISFILE);
+ jboolean r = S_ISDIR (sb.st_mode);
+ return query == DIRECTORY ? r : ! r;
+#else
+ return false;
+#endif
+}
+
+jlong
+java::io::File::attr (jint query)
+{
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+
+#ifdef HAVE_STAT
+ struct stat sb;
+ // FIXME: not sure about return value here.
+ if (::stat (buf, &sb))
+ return 0;
+
+ JvAssert (query == MODIFIED || query == LENGTH);
+ return query == MODIFIED ? (jlong)sb.st_mtime * 1000 : sb.st_size;
+#else
+ // There's no good choice here.
+ return 23;
+#endif
+}
+
+// These two methods are used to maintain dynamically allocated
+// buffers for getCanonicalPath without the overhead of calling
+// realloc every time a buffer is modified. Buffers are sized
+// at the smallest multiple of CHUNKSIZ that is greater than or
+// equal to the desired length. The default CHUNKSIZ is 256,
+// longer than most paths, so in most cases a getCanonicalPath
+// will require only one malloc per buffer.
+
+#define CHUNKLOG 8
+#define CHUNKSIZ (1 << CHUNKLOG)
+
+static int
+nextChunkSize (int size)
+{
+ return ((size >> CHUNKLOG) + ((size & (CHUNKSIZ - 1)) ? 1 : 0)) << CHUNKLOG;
+}
+
+static char *
+maybeGrowBuf (char *buf, int *size, int required)
+{
+ if (required > *size)
+ {
+ *size = nextChunkSize (required);
+ buf = (char *) _Jv_Realloc (buf, *size);
+ }
+ return buf;
+}
+
+// Return a canonical representation of the pathname of this file. On
+// the GNU system this involves the removal of redundant separators,
+// references to "." and "..", and symbolic links.
+//
+// The conversion proceeds on a component-by-component basis: symbolic
+// links and references to ".." are resolved as and when they occur.
+// This means that if "/foo/bar" is a symbolic link to "/baz" then the
+// canonical form of "/foo/bar/.." is "/" and not "/foo".
+//
+// In order to mimic the behaviour of proprietary JVMs, non-existant
+// path components are allowed (a departure from the normal GNU system
+// convention). This means that if "/foo/bar" is a symbolic link to
+// "/baz", the canonical form of "/non-existant-directory/../foo/bar"
+// is "/baz".
+
+jstring
+java::io::File::getCanonicalPath (void)
+{
+ jstring path = getAbsolutePath ();
+
+ int len = JvGetStringUTFLength (path);
+ int srcl = nextChunkSize (len + 1);
+ char *src = (char *) _Jv_Malloc (srcl);
+ JvGetStringUTFRegion (path, 0, path->length(), src);
+ src[len] = '\0';
+ int srci = 1;
+
+ int dstl = nextChunkSize (2);
+ char *dst = (char *) _Jv_Malloc (dstl);
+ dst[0] = '/';
+ int dsti = 1;
+
+ bool fschecks = true;
+
+ while (src[srci] != '\0')
+ {
+ // Skip slashes.
+ while (src[srci] == '/')
+ srci++;
+ int tmpi = srci;
+ // Find next slash.
+ while (src[srci] != '/' && src[srci] != '\0')
+ srci++;
+ if (srci == tmpi)
+ // We hit the end.
+ break;
+ len = srci - tmpi;
+
+ // Handle "." and "..".
+ if (len == 1 && src[tmpi] == '.')
+ continue;
+ if (len == 2 && src[tmpi] == '.' && src[tmpi + 1] == '.')
+ {
+ while (dsti > 1 && dst[dsti - 1] != '/')
+ dsti--;
+ if (dsti != 1)
+ dsti--;
+ // Reenable filesystem checking if disabled, as we might
+ // have reversed over whatever caused the problem before.
+ // At least one proprietary JVM has inconsistencies because
+ // it does not do this.
+ fschecks = true;
+ continue;
+ }
+
+ // Handle real path components.
+ dst = maybeGrowBuf (dst, &dstl, dsti + (dsti > 1 ? 1 : 0) + len + 1);
+ int dsti_save = dsti;
+ if (dsti > 1)
+ dst[dsti++] = '/';
+ strncpy (&dst[dsti], &src[tmpi], len);
+ dsti += len;
+ if (fschecks == false)
+ continue;
+
+#if defined (HAVE_LSTAT) && defined (HAVE_READLINK)
+ struct stat sb;
+ dst[dsti] = '\0';
+ if (::lstat (dst, &sb) == 0)
+ {
+ if (S_ISLNK (sb.st_mode))
+ {
+ int tmpl = CHUNKSIZ;
+ char *tmp = (char *) _Jv_Malloc (tmpl);
+
+ while (1)
+ {
+ tmpi = ::readlink (dst, tmp, tmpl);
+ if (tmpi < 1)
+ {
+ _Jv_Free (src);
+ _Jv_Free (dst);
+ _Jv_Free (tmp);
+ throw new IOException (
+ JvNewStringLatin1 ("readlink failed"));
+ }
+ if (tmpi < tmpl)
+ break;
+ tmpl += CHUNKSIZ;
+ tmp = (char *) _Jv_Realloc (tmp, tmpl);
+ }
+
+ // Prepend the link's path to src.
+ tmp = maybeGrowBuf (tmp, &tmpl, tmpi + strlen (&src[srci]) + 1);
+ strcpy(&tmp[tmpi], &src[srci]);
+ _Jv_Free (src);
+ src = tmp;
+ srcl = tmpl;
+ srci = 0;
+
+ // Either replace or append dst depending on whether the
+ // link is relative or absolute.
+ dsti = src[0] == '/' ? 1 : dsti_save;
+ }
+ }
+ else
+ {
+ // Something doesn't exist, or we don't have permission to
+ // read it, or a previous path component is a directory, or
+ // a symlink is looped. Whatever, we can't check the
+ // filesystem any more.
+ fschecks = false;
+ }
+#endif // HAVE_LSTAT && HAVE_READLINK
+ }
+ dst[dsti] = '\0';
+
+ // FIXME: what encoding to assume for file names? This affects many
+ // calls.
+ path = JvNewStringUTF (dst);
+ _Jv_Free (src);
+ _Jv_Free (dst);
+ return path;
+}
+
+jboolean
+java::io::File::isAbsolute (void)
+{
+ return path->length() > 0 && path->charAt(0) == '/';
+}
+
+jobjectArray
+java::io::File::performList (java::io::FilenameFilter *filter,
+ java::io::FileFilter *fileFilter,
+ java::lang::Class *result_type)
+{
+ /* Some systems have dirent.h, but no directory reading functions like
+ opendir. */
+#if defined(HAVE_DIRENT_H) && defined(HAVE_OPENDIR)
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+
+ DIR *dir = opendir (buf);
+ if (! dir)
+ return NULL;
+
+ java::util::ArrayList *list = new java::util::ArrayList ();
+ struct dirent *d;
+ while ((d = readdir (dir)) != NULL)
+ {
+ // Omit "." and "..".
+ if (d->d_name[0] == '.'
+ && (d->d_name[1] == '\0'
+ || (d->d_name[1] == '.' && d->d_name[2] == '\0')))
+ continue;
+
+ jstring name = JvNewStringUTF (d->d_name);
+ if (filter && ! filter->accept(this, name))
+ continue;
+
+ if (result_type == &java::io::File::class$)
+ {
+ java::io::File *file = new java::io::File (this, name);
+ if (fileFilter && ! fileFilter->accept(file))
+ continue;
+
+ list->add(file);
+ }
+ else
+ list->add(name);
+ }
+
+ closedir (dir);
+
+ jobjectArray ret = JvNewObjectArray (list->size(), result_type, NULL);
+ list->toArray(ret);
+ return ret;
+#else /* HAVE_DIRENT_H && HAVE_OPENDIR */
+ return NULL;
+#endif /* HAVE_DIRENT_H && HAVE_OPENDIR */
+}
+
+jboolean
+java::io::File::performMkdir (void)
+{
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+
+#ifdef HAVE_MKDIR
+ return ::mkdir (buf, 0755) == 0;
+#else
+ return false;
+#endif
+}
+
+jboolean
+java::io::File::setFilePermissions (jboolean enable,
+ jboolean ownerOnly,
+ jint permissions)
+{
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+ JvAssert (permissions == READ || permissions == WRITE || permissions == EXEC);
+#if defined (HAVE_STAT) && defined (HAVE_CHMOD)
+ mode_t mode = 0;
+
+ struct stat sb;
+ if (::stat (buf, &sb))
+ return false;
+
+ if (ownerOnly)
+ {
+ if (permissions == READ)
+ mode |= S_IRUSR;
+ else if (permissions == WRITE)
+ mode |= S_IWUSR;
+ else if (permissions == EXEC)
+ mode |= S_IXUSR;
+ }
+ else
+ {
+ if (permissions == READ)
+ mode |= (S_IRUSR | S_IRGRP | S_IROTH);
+ else if (permissions == WRITE)
+ mode |= (S_IWUSR | S_IWGRP | S_IWOTH);
+ else if (permissions == EXEC)
+ mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
+ }
+
+ if (enable)
+ mode = sb.st_mode | mode;
+ else
+ mode = sb.st_mode & ~mode;
+
+ if (::chmod(buf, mode) < 0)
+ return false;
+ return true;
+#else
+ return false;
+#endif
+}
+
+jboolean
+java::io::File::performSetReadOnly (void)
+{
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+
+#if defined (HAVE_STAT) && defined (HAVE_CHMOD)
+ struct stat sb;
+ if (::stat (buf, &sb))
+ return false;
+
+ if (::chmod(buf, sb.st_mode & 0555))
+ return false;
+ return true;
+#else
+ return false;
+#endif
+}
+
+JArray< ::java::io::File *>*
+java::io::File::performListRoots ()
+{
+ ::java::io::File *f = new ::java::io::File (JvNewStringLatin1 ("/"));
+ JArray<java::io::File *> *unixroot
+ = reinterpret_cast <JArray<java::io::File *>*>
+ (JvNewObjectArray (1, &java::io::File::class$, f));
+ elements (unixroot) [0] = f;
+ return unixroot;
+}
+
+jboolean
+java::io::File::performRenameTo (File *dest)
+{
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+ char *buf2
+ = (char *) __builtin_alloca (JvGetStringUTFLength (dest->path) + 1);
+ total = JvGetStringUTFRegion (dest->path, 0, dest->path->length(), buf2);
+ buf2[total] = '\0';
+
+#ifdef HAVE_RENAME
+ return ::rename (buf, buf2) == 0;
+#else
+ return false;
+#endif
+}
+
+jboolean
+java::io::File::performSetLastModified (jlong time)
+{
+#ifdef HAVE_UTIME
+ utimbuf tb;
+
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+
+ tb.actime = time / 1000;
+ tb.modtime = time / 1000;
+ return (::utime (buf, &tb) == 0);
+#else
+ return false;
+#endif
+}
+
+jboolean
+java::io::File::performCreate (void)
+{
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+
+ int fd = ::open (buf, O_CREAT | O_EXCL, 0644);
+
+ if (fd < 0)
+ {
+ if (errno == EEXIST)
+ return false;
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+ }
+ else
+ {
+ ::close (fd);
+ return true;
+ }
+}
+
+jboolean
+java::io::File::performDelete (void)
+{
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
+ buf[total] = '\0';
+
+#ifdef HAVE_UNLINK
+#ifdef HAVE_RMDIR
+ if (! ::rmdir (buf))
+ return true;
+ if (errno == ENOTDIR)
+#endif // HAVE_RMDIR
+ return ::unlink (buf) == 0;
+#endif // HAVE_UNLINK
+ return false;
+}
+
+void
+java::io::File::init_native ()
+{
+#ifdef MAXPATHLEN
+ maxPathLen = MAXPATHLEN;
+#else
+ /* Some systems do not have a limit on the length of a file name,
+ the GNU system is one such example. */
+ maxPathLen = 0;
+#endif
+ caseSensitive = true;
+}
diff --git a/libjava/java/io/natFileWin32.cc b/libjava/java/io/natFileWin32.cc
new file mode 100644
index 000000000..316977b08
--- /dev/null
+++ b/libjava/java/io/natFileWin32.cc
@@ -0,0 +1,374 @@
+// natFileWin32.cc - Native part of File class for Win32.
+
+/* Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#undef STRICT
+
+#include <java/io/File.h>
+#include <java/io/IOException.h>
+#include <java/util/Vector.h>
+#include <java/lang/String.h>
+#include <java/io/FilenameFilter.h>
+#include <java/io/FileFilter.h>
+#include <java/lang/System.h>
+
+// Java timestamps are milliseconds since the UNIX epoch (00:00:00 UTC on
+// January 1, 1970) while Win32 file-times are 100-nanosecond intervals
+// since the Win32 epoch (00:00:00 UTC on January 1, 1601). The following
+// constant represents the number of milliseconds to be added to a
+// Java timestamp to base it on the Win32 epoch.
+//
+// There were 369 years between 1601 and 1970, including 89 leap years
+// (since 1700, 1800 and 1900 were not leap years):
+//
+// (89*366 + 280*365) days * 86400 seconds/day = 11644473600 seconds
+//
+#define WIN32_EPOCH_MILLIS 11644473600000LL
+
+jboolean
+java::io::File::_access (jint query)
+{
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
+ if (!canon)
+ return false;
+
+ JvAssert (query == READ || query == WRITE || query == EXISTS
+ || query == EXEC);
+
+ // FIXME: Is it possible to differentiate between existing and reading?
+ // If the file exists but cannot be read because of the secuirty attributes
+ // on an NTFS disk this wont work (it reports it can be read but cant)
+ // Could we use something from the security API?
+ DWORD attributes = GetFileAttributes (canon);
+ // FIXME: handle EXEC
+ if (query == EXEC)
+ return false;
+ if ((query == EXISTS) || (query == READ))
+ return (attributes == 0xffffffff) ? false : true;
+ else
+ return ((attributes != 0xffffffff) &&
+ ((attributes & FILE_ATTRIBUTE_READONLY) == 0)) ? true : false;
+}
+
+jboolean
+java::io::File::_stat (jint query)
+{
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
+ if (!canon)
+ return false;
+
+ JvAssert (query == DIRECTORY || query == ISFILE);
+
+ DWORD attributes = GetFileAttributes (canon);
+ if (attributes == 0xffffffff)
+ return false;
+
+ if (query == DIRECTORY)
+ return attributes & FILE_ATTRIBUTE_DIRECTORY ? true : false;
+ else
+ return attributes & FILE_ATTRIBUTE_DIRECTORY ? false : true;
+}
+
+jlong
+java::io::File::attr (jint query)
+{
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
+ if (!canon)
+ return false;
+
+ JvAssert (query == MODIFIED || query == LENGTH);
+
+ WIN32_FIND_DATA info;
+ HANDLE sHandle;
+ if ( ( sHandle = FindFirstFile( canon, &info)) == INVALID_HANDLE_VALUE)
+ return 0;
+
+ FindClose( sHandle);
+
+ if (query == LENGTH)
+ return ((long long)info.nFileSizeHigh) << 32
+ | (unsigned long long)info.nFileSizeLow;
+ else
+ {
+ // The file time as returned by Windows is in terms of the number
+ // of 100-nanosecond intervals since 00:00:00 UTC, January 1, 1601.
+ return (((((long long)info.ftLastWriteTime.dwHighDateTime) << 32)
+ | ((unsigned long long)info.ftLastWriteTime.dwLowDateTime))
+ - WIN32_EPOCH_MILLIS*10000LL) / 10000LL;
+ }
+}
+
+jstring
+java::io::File::getCanonicalPath (void)
+{
+ JV_TEMP_STRING_WIN32 (cpath, path);
+
+ // If the filename is blank, use the current directory.
+ LPCTSTR thepath = cpath.buf();
+ if (*thepath == 0)
+ thepath = _T(".");
+
+ LPTSTR unused;
+ TCHAR buf2[MAX_PATH];
+ if(!GetFullPathName(thepath, MAX_PATH, buf2, &unused))
+ throw new IOException (JvNewStringLatin1 ("GetFullPathName failed"));
+
+ return _Jv_Win32NewString (buf2);
+}
+
+jboolean
+java::io::File::isAbsolute (void)
+{
+ // See if the path represents a Windows UNC network path.
+ if (path->length () > 2
+ && (path->charAt (0) == '\\') && (path->charAt (1) == '\\'))
+ return true;
+
+ // Note that the path is not an absolute path even if it starts with
+ // a '/' or a '\' because it lacks a drive specifier.
+
+ if (path->length() < 3)
+ return false;
+ // Hard-code A-Za-z because Windows (I think) can't use non-ASCII
+ // letters as drive names.
+ if ((path->charAt(0) < 'a' || path->charAt(0) > 'z')
+ && (path->charAt(0) < 'A' || path->charAt(0) > 'Z'))
+ return false;
+ return (path->charAt(1) == ':'
+ && (path->charAt(2) == '/' || path->charAt(2) == '\\'));
+}
+
+void java::io::File::init_native ()
+{
+ maxPathLen = MAX_PATH;
+ caseSensitive = false;
+}
+
+jobjectArray
+java::io::File::performList (java::io::FilenameFilter *filter,
+ java::io::FileFilter *fileFilter,
+ java::lang::Class *clazz)
+{
+ jstring canon = getCanonicalPath();
+ if (! canon)
+ return NULL;
+
+ int len = canon->length();
+ TCHAR buf[len + 5];
+
+ JV_TEMP_STRING_WIN32(canonstr, canon);
+
+ _tcscpy(buf, canonstr);
+ if (buf[len - 1] == _T('\\'))
+ _tcscpy (&buf[len], _T("*.*"));
+ else
+ _tcscpy (&buf[len], _T("\\*.*"));
+
+ WIN32_FIND_DATA data;
+ HANDLE handle = FindFirstFile (buf, &data);
+ if (handle == INVALID_HANDLE_VALUE)
+ return NULL;
+
+ java::util::Vector *vec = new java::util::Vector ();
+
+ do
+ {
+ if (_tcscmp (data.cFileName, _T(".")) &&
+ _tcscmp (data.cFileName, _T("..")))
+ {
+ jstring name = _Jv_Win32NewString (data.cFileName);
+
+ if (filter && !filter->accept(this, name))
+ continue;
+ if (clazz == &java::io::File::class$)
+ {
+ java::io::File *file = new java::io::File (this, name);
+ if (fileFilter && !fileFilter->accept(file))
+ continue;
+ vec->addElement (file);
+ }
+ else
+ vec->addElement (name);
+ }
+ }
+ while (FindNextFile (handle, &data));
+
+ if (GetLastError () != ERROR_NO_MORE_FILES)
+ return NULL;
+
+ FindClose (handle);
+
+ jobjectArray ret = JvNewObjectArray (vec->size(), clazz, NULL);
+ vec->copyInto (ret);
+ return ret;
+}
+
+jboolean
+java::io::File::setFilePermissions (jboolean enable,
+ jboolean ownerOnly,
+ jint permissions)
+{
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
+ if (!canon)
+ return false;
+
+ DWORD attrs = GetFileAttributes (canon);
+ if (attrs != INVALID_FILE_ATTRIBUTES)
+ {
+ // FIXME: implement
+ return false;
+ }
+ else
+ return false;
+}
+
+jboolean
+java::io::File::performMkdir (void)
+{
+ JV_TEMP_STRING_WIN32 (cpath, path);
+ return (CreateDirectory(cpath, NULL)) ? true : false;
+}
+
+jboolean
+java::io::File::performRenameTo (File *dest)
+{
+ JV_TEMP_STRING_WIN32 (pathFrom, path);
+ JV_TEMP_STRING_WIN32 (pathTo, dest->path);
+ return (MoveFile(pathFrom, pathTo)) ? true : false;
+}
+
+jboolean
+java::io::File::performDelete ()
+{
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
+ if (!canon)
+ return false;
+
+ DWORD attributes = GetFileAttributes (canon);
+ if (attributes == 0xffffffff)
+ return false;
+
+ if (attributes & FILE_ATTRIBUTE_DIRECTORY)
+ return (RemoveDirectory (canon)) ? true : false;
+ else
+ return (DeleteFile (canon)) ? true : false;
+}
+
+jboolean java::io::File::performCreate (void)
+{
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
+ if (!canon)
+ return false;
+
+ HANDLE h = CreateFile (canon, 0, 0, NULL, CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle (h);
+ return true;
+ }
+ else
+ {
+ if (GetLastError () == ERROR_ALREADY_EXISTS)
+ return false;
+ else
+ throw new IOException (JvNewStringLatin1 ("CreateFile failed"));
+ }
+}
+
+jboolean java::io::File::performSetReadOnly ()
+{
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
+ if (!canon)
+ return false;
+
+ DWORD attrs = GetFileAttributes (canon);
+ if (attrs != INVALID_FILE_ATTRIBUTES)
+ {
+ if (SetFileAttributes (canon, attrs | FILE_ATTRIBUTE_READONLY) != 0)
+ return true;
+ else
+ return false;
+ }
+ else
+ return false;
+}
+
+jboolean java::io::File::performSetLastModified (jlong time)
+{
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
+ if (!canon)
+ return false;
+
+ FILETIME modTime;
+ long long mTime100ns = ((long long) time /* Ha! */
+ + WIN32_EPOCH_MILLIS) * 10000LL;
+
+ modTime.dwLowDateTime = (DWORD) mTime100ns;
+ modTime.dwHighDateTime = (DWORD) (mTime100ns >> 32);
+
+ jboolean retVal = false;
+ HANDLE h = CreateFile (canon, FILE_WRITE_ATTRIBUTES,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, 0, NULL);
+
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ if (SetFileTime (h, NULL, &modTime, &modTime) != 0)
+ retVal = true;
+
+ CloseHandle (h);
+ }
+
+ return retVal;
+}
+
+JArray<java::io::File*>* java::io::File::performListRoots ()
+{
+ DWORD drivesBitmap = GetLogicalDrives ();
+ DWORD mask;
+
+ // Possible drive letters are from ASCII 'A'-'Z'.
+ int numDrives = 0;
+ mask = 1;
+ for (int i = 0; i < 26; i++)
+ {
+ if ((drivesBitmap & mask) != 0)
+ numDrives++;
+ mask <<= 1;
+ }
+
+ JArray<java::io::File *> *roots
+ = reinterpret_cast <JArray<java::io::File *>*>
+ (JvNewObjectArray (numDrives, &java::io::File::class$, NULL));
+
+ ::java::io::File **rootsArray = elements (roots);
+
+ char aDriveRoot[] = {'A', ':', '\\', '\0'};
+ mask = 1;
+ for (int i = 0, j = 0; i < 26; i++)
+ {
+ if ((drivesBitmap & mask) != 0)
+ {
+ rootsArray[j]
+ = new ::java::io::File (JvNewStringLatin1 (aDriveRoot));
+ j++;
+ }
+ mask <<= 1;
+ aDriveRoot[0]++;
+ }
+
+ return roots;
+}
diff --git a/libjava/java/io/natVMObjectInputStream.cc b/libjava/java/io/natVMObjectInputStream.cc
new file mode 100644
index 000000000..eccf0eb02
--- /dev/null
+++ b/libjava/java/io/natVMObjectInputStream.cc
@@ -0,0 +1,71 @@
+// natVMObjectInputStream.cc - Native part of VMObjectInputStream class.
+
+/* Copyright (C) 1998, 1999, 2000, 2001, 2005, 2006, 2007
+ Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the ObjectInputStream "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+
+#include <gcj/cni.h>
+#include <jvm.h>
+#include <gcj/method.h>
+
+#include <java/io/VMObjectInputStream.h>
+#include <java/io/IOException.h>
+#include <java/lang/Class.h>
+#include <java/lang/reflect/Modifier.h>
+#include <java/lang/reflect/Method.h>
+#include <java/lang/ArrayIndexOutOfBoundsException.h>
+#include <java/lang/SecurityManager.h>
+#include <java/lang/reflect/Constructor.h>
+#include <java/lang/reflect/Method.h>
+#include <java-stack.h>
+
+#ifdef __GCJ_DEBUG
+#include <java/lang/System.h>
+#include <java/io/PrintStream.h>
+#endif
+
+jobject
+java::io::VMObjectInputStream::allocateObject (jclass klass, jclass,
+ ::java::lang::reflect::Constructor *ctr)
+{
+ jobject obj = NULL;
+ using namespace java::lang::reflect;
+
+ try
+ {
+ JvAssert (klass && ! klass->isArray ());
+ if (klass->isInterface() || Modifier::isAbstract(klass->getModifiers()))
+ obj = NULL;
+ else
+ {
+ obj = _Jv_AllocObject (klass);
+ }
+ }
+ catch (jthrowable t)
+ {
+ return NULL;
+ }
+
+ jmethodID meth = _Jv_FromReflectedConstructor (ctr);
+
+ // This is a bit inefficient, and a bit of a hack, since we don't
+ // actually use the Method and since what is returned isn't
+ // technically a Method. We can't use Method.invoke as it looks up
+ // the declared method.
+ JArray<jclass> *arg_types
+ = (JArray<jclass> *) JvNewObjectArray (0, &java::lang::Class::class$,
+ NULL);
+
+ // We lie about this being a constructor. If we put `true' here
+ // then _Jv_CallAnyMethodA would try to allocate the object for us.
+ _Jv_CallAnyMethodA (obj, JvPrimClass (void), meth, false, arg_types, NULL);
+
+ return obj;
+}
diff --git a/libjava/java/io/natVMObjectStreamClass.cc b/libjava/java/io/natVMObjectStreamClass.cc
new file mode 100644
index 000000000..847b540f0
--- /dev/null
+++ b/libjava/java/io/natVMObjectStreamClass.cc
@@ -0,0 +1,87 @@
+// natVMObjectStreamClass.cc - Native part of VMObjectStreamClass class.
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This VMObjectStreamClass is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the ObjectInputStream "LIBGCJ_LICENSE" for
+details. */
+
+#include <gcj/cni.h>
+#include <jvm.h>
+
+#include <java/io/VMObjectStreamClass.h>
+#include <java/lang/Class.h>
+#include <java/lang/reflect/Field.h>
+
+using namespace java::lang::reflect;
+
+jboolean
+java::io::VMObjectStreamClass::hasClassInitializer (jclass klass)
+{
+ if (klass->isPrimitive())
+ return false;
+ _Jv_Method *meth = _Jv_GetMethodLocal(klass, gcj::clinit_name,
+ gcj::void_signature);
+ return (meth != NULL);
+}
+
+void
+java::io::VMObjectStreamClass::setDoubleNative (Field *f, jobject obj,
+ jdouble val)
+{
+ f->setDouble (NULL, obj, val, false);
+}
+
+void
+java::io::VMObjectStreamClass::setFloatNative (Field *f, jobject obj,
+ jfloat val)
+{
+ f->setFloat (NULL, obj, val, false);
+}
+
+void
+java::io::VMObjectStreamClass::setLongNative (Field *f, jobject obj, jlong val)
+{
+ f->setLong (NULL, obj, val, false);
+}
+
+void
+java::io::VMObjectStreamClass::setIntNative (Field *f, jobject obj, jint val)
+{
+ f->setInt (NULL, obj, val, false);
+}
+
+void
+java::io::VMObjectStreamClass::setShortNative (Field *f, jobject obj,
+ jshort val)
+{
+ f->setShort (NULL, obj, val, false);
+}
+
+void
+java::io::VMObjectStreamClass::setCharNative (Field *f, jobject obj, jchar val)
+{
+ f->setChar (NULL, obj, val, false);
+}
+
+void
+java::io::VMObjectStreamClass::setByteNative (Field *f, jobject obj, jbyte val)
+{
+ f->setByte (NULL, obj, val, false);
+}
+
+void
+java::io::VMObjectStreamClass::setBooleanNative (Field *f, jobject obj,
+ jboolean val)
+{
+ f->setBoolean (NULL, obj, val, false);
+}
+
+void
+java::io::VMObjectStreamClass::setObjectNative (Field *f, jobject obj,
+ jobject val)
+{
+ f->set (NULL, obj, val, f->getType(), false);
+}