This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: gnu.java.nio
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 20 Apr 2004 12:44:13 +0200
- Subject: FYI: Patch: gnu.java.nio
Hi list,
I just commited the attached patch to merge fixes made in GNU classpath
to java.nio.
Michael
2004-04-20 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/FileLockImpl.java
(static): Removed, not needed anymore.
* gnu/java/nio/channels/FileChannelImpl.java
(FileChannelImpl): Made final.
(mode): Made private.
(READ, WRITE, APPEND): Made public.
(EXCL, SYNC, DSYNC): Likewise.
(static): Load native JNI library, when needed.
(length): Unused, removed.
(available): Made public.
(implPosition): Throws IOException.
(seek): Likewise.
(implTruncate): Likewise.
(unlock): Likewise.
(lock): Likewise.
Index: gnu/java/nio/FileLockImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/FileLockImpl.java,v
retrieving revision 1.9
diff -u -r1.9 FileLockImpl.java
--- gnu/java/nio/FileLockImpl.java 29 Feb 2004 19:13:45 -0000 1.9
+++ gnu/java/nio/FileLockImpl.java 20 Apr 2004 10:43:10 -0000
@@ -38,9 +38,8 @@
package gnu.java.nio;
-import java.io.FileDescriptor;
import java.io.IOException;
-import java.nio.channels.*;
+import java.nio.channels.FileLock;
import gnu.classpath.Configuration;
import gnu.java.nio.channels.FileChannelImpl;
@@ -50,15 +49,6 @@
*/
public class FileLockImpl extends FileLock
{
- static
- {
- // load the shared library needed for native methods.
- if (Configuration.INIT_LOAD_LIBRARY)
- {
- System.loadLibrary ("javanio");
- }
- }
-
private FileChannelImpl ch;
public FileLockImpl (FileChannelImpl channel, long position,
Index: gnu/java/nio/channels/FileChannelImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/channels/FileChannelImpl.java,v
retrieving revision 1.1
diff -u -r1.1 FileChannelImpl.java
--- gnu/java/nio/channels/FileChannelImpl.java 29 Feb 2004 19:09:27 -0000 1.1
+++ gnu/java/nio/channels/FileChannelImpl.java 20 Apr 2004 10:43:10 -0000
@@ -39,12 +39,19 @@
package gnu.java.nio.channels;
import gnu.classpath.Configuration;
-import gnu.gcj.RawData;
import gnu.java.nio.FileLockImpl;
-import java.io.*;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
-import java.nio.channels.*;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.nio.channels.NonReadableChannelException;
+import java.nio.channels.NonWritableChannelException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
/**
* This file is not user visible !
@@ -54,22 +61,33 @@
* Upon a Input/Output/RandomAccessFile object.
*/
-public class FileChannelImpl extends FileChannel
+public final class FileChannelImpl extends FileChannel
{
- int mode;
// These are WHENCE values for seek.
static final int SET = 0;
static final int CUR = 1;
// These are mode values for open().
- static final int READ = 1;
- static final int WRITE = 2;
- static final int APPEND = 4;
+ public static final int READ = 1;
+ public static final int WRITE = 2;
+ public static final int APPEND = 4;
// EXCL is used only when making a temp file.
- static final int EXCL = 8;
- static final int SYNC = 16;
- static final int DSYNC = 32;
+ public static final int EXCL = 8;
+ public static final int SYNC = 16;
+ public static final int DSYNC = 32;
+
+ private static native void init();
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary("javanio");
+ }
+
+ init();
+ }
/**
* This is the actual native file descriptor value
@@ -81,8 +99,8 @@
// efficient way to accomplish that.
private int fd = -1;
- int length;
private long pos;
+ private int mode;
public FileChannelImpl ()
{
@@ -95,8 +113,12 @@
this.mode = mode;
}
- private static native void init();
- static { init (); }
+ /* Used by init() (native code) */
+ FileChannelImpl (int fd, int mode)
+ {
+ this.fd = fd;
+ this.mode = mode;
+ }
public static FileChannelImpl in;
public static FileChannelImpl out;
@@ -104,19 +126,12 @@
private native int open (String path, int mode) throws FileNotFoundException;
- /** Attach to an already-opened file. */
- public FileChannelImpl (int desc, int mode)
- {
- fd = desc;
- this.mode = mode;
- }
-
- native int available () throws IOException;
- private native long implPosition ();
- private native void seek (long newPosition);
- private native void implTruncate (long size);
+ public native int available () throws IOException;
+ private native long implPosition () throws IOException;
+ private native void seek (long newPosition) throws IOException;
+ private native void implTruncate (long size) throws IOException;
- public native void unlock (long pos, long len);
+ public native void unlock (long pos, long len) throws IOException;
public native long size () throws IOException;
@@ -350,7 +365,7 @@
* Otherwise return false.
*/
private native boolean lock(long position, long size,
- boolean shared, boolean wait);
+ boolean shared, boolean wait) throws IOException;
public FileLock lock (long position, long size, boolean shared)
throws IOException