summaryrefslogtreecommitdiffstats
path: root/libjava/gnu/java
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-05-14 06:37:59 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-05-14 06:37:59 +0000
commit87a1da8d641b8769b808ab2e806027e237261a23 (patch)
tree24fccf7ef3db6564bf6419c09974cfbc9fba0c84 /libjava/gnu/java
parent979e2687de7fcb92a1b39364206d02cda2f1dd25 (diff)
downloadppe42-gcc-87a1da8d641b8769b808ab2e806027e237261a23.tar.gz
ppe42-gcc-87a1da8d641b8769b808ab2e806027e237261a23.zip
2003-05-14 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/FileLockImpl.java (released): New member variable. (FileLockImpl): Initialize released. (releaseImpl): New native method. (release): Implemented. * gnu/java/nio/SelectorImpl.java: Reformatted. * gnu/java/nio/SelectionKeyImpl.java: Reformatted. * gnu/java/nio/ServerSocketChannelImpl.java: Reformatted. (accept): Throws IOException. * gnu/java/nio/SocketChannelImpl.java: Reformatted. (implConfigureBlocking): Throws IOException. (connect): Likewise. (read): Likewise. (write): Likewise. * gnu/java/nio/natFileLockImpl.cc: New file. * java/nio/channels/FileLock.java: Reformatted. * Makefile.am: (ordinary_java_source_files): Added gnu/java/nio/FileLockImpl.java. (nat_source_files): Added gnu/java/nio/natFileLockImpl.cc. * Makefile.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66799 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/gnu/java')
-rw-r--r--libjava/gnu/java/nio/FileLockImpl.java22
-rw-r--r--libjava/gnu/java/nio/SelectionKeyImpl.java2
-rw-r--r--libjava/gnu/java/nio/SelectorImpl.java10
-rw-r--r--libjava/gnu/java/nio/ServerSocketChannelImpl.java12
-rw-r--r--libjava/gnu/java/nio/SocketChannelImpl.java60
-rw-r--r--libjava/gnu/java/nio/natFileLockImpl.cc25
6 files changed, 85 insertions, 46 deletions
diff --git a/libjava/gnu/java/nio/FileLockImpl.java b/libjava/gnu/java/nio/FileLockImpl.java
index 2e55f6bb657..088e552bea2 100644
--- a/libjava/gnu/java/nio/FileLockImpl.java
+++ b/libjava/gnu/java/nio/FileLockImpl.java
@@ -35,29 +35,41 @@ 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 gnu.java.nio;
+import java.io.FileDescriptor;
+import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
/**
* @author Michael Koch
+ * @since 1.4
*/
public class FileLockImpl extends FileLock
{
- public FileLockImpl (FileChannel channel, long position, long size,
- boolean shared)
+ private FileDescriptor fd;
+ private boolean released;
+
+ public FileLockImpl (FileDescriptor fd, FileChannel channel, long position,
+ long size, boolean shared)
{
super (channel, position, size, shared);
+ this.fd = fd;
+ this.released = false;
}
public boolean isValid ()
{
- throw new Error ("Not implemented");
+ return (released || !channel.isOpen ());
}
- public void release ()
+ private native void releaseImpl () throws IOException;
+
+ public synchronized void release () throws IOException
{
- throw new Error ("Not implemented");
+ releaseImpl ();
+ released = true;
}
}
diff --git a/libjava/gnu/java/nio/SelectionKeyImpl.java b/libjava/gnu/java/nio/SelectionKeyImpl.java
index 5763d6880d3..72dc20b15b8 100644
--- a/libjava/gnu/java/nio/SelectionKeyImpl.java
+++ b/libjava/gnu/java/nio/SelectionKeyImpl.java
@@ -50,7 +50,7 @@ public class SelectionKeyImpl extends AbstractSelectionKey
SelectorImpl impl;
SelectableChannel ch;
- public SelectionKeyImpl(SelectableChannel ch, SelectorImpl impl, int fd)
+ public SelectionKeyImpl (SelectableChannel ch, SelectorImpl impl, int fd)
{
this.ch = ch;
this.impl = impl;
diff --git a/libjava/gnu/java/nio/SelectorImpl.java b/libjava/gnu/java/nio/SelectorImpl.java
index 0b513f9da52..e3eed255501 100644
--- a/libjava/gnu/java/nio/SelectorImpl.java
+++ b/libjava/gnu/java/nio/SelectorImpl.java
@@ -261,16 +261,16 @@ public class SelectorImpl extends AbstractSelector
// return impl;
// }
// else
-
+
if (ch instanceof SocketChannelImpl)
- {
+ {
SocketChannelImpl sc = (SocketChannelImpl) ch;
SelectionKeyImpl impl = new SelectionKeyImpl (ch, this, sc.fd);
add (impl);
impl.interestOps (ops);
impl.attach (att);
return impl;
- }
+ }
else if (ch instanceof DatagramChannelImpl)
{
DatagramChannelImpl dc = (DatagramChannelImpl) ch;
@@ -290,9 +290,9 @@ public class SelectorImpl extends AbstractSelector
return impl;
}
else
- {
+ {
System.err.println ("INTERNAL ERROR, no known channel type");
- }
+ }
return null;
}
diff --git a/libjava/gnu/java/nio/ServerSocketChannelImpl.java b/libjava/gnu/java/nio/ServerSocketChannelImpl.java
index 039b50308d6..0b3fc66e981 100644
--- a/libjava/gnu/java/nio/ServerSocketChannelImpl.java
+++ b/libjava/gnu/java/nio/ServerSocketChannelImpl.java
@@ -73,15 +73,15 @@ class ServerSocketChannelImpl extends ServerSocketChannel
public void finalizer()
{
if (connected)
- {
+ {
try
{
- close();
+ close ();
}
catch (Exception e)
{
}
- }
+ }
}
protected void implCloseSelectableChannel () throws IOException
@@ -91,12 +91,12 @@ class ServerSocketChannelImpl extends ServerSocketChannel
fd = SocketChannelImpl.SocketCreate ();
}
- protected void implConfigureBlocking (boolean block) throws IOException
+ protected void implConfigureBlocking (boolean blocking) throws IOException
{
- blocking = block;
+ this.blocking = blocking;
}
- public SocketChannel accept ()
+ public SocketChannel accept () throws IOException
{
SocketChannelImpl result = new SocketChannelImpl (provider ());
result.sa = new InetSocketAddress (0);
diff --git a/libjava/gnu/java/nio/SocketChannelImpl.java b/libjava/gnu/java/nio/SocketChannelImpl.java
index 9f2de278d81..65ca62341ae 100644
--- a/libjava/gnu/java/nio/SocketChannelImpl.java
+++ b/libjava/gnu/java/nio/SocketChannelImpl.java
@@ -80,37 +80,36 @@ public class SocketChannelImpl extends SocketChannel
public void finalizer()
{
if (connected)
- {
+ {
try
{
- close();
+ close ();
}
catch (Exception e)
{
}
- }
+ }
}
- protected void implCloseSelectableChannel()
+ protected void implCloseSelectableChannel () throws IOException
{
connected = false;
SocketClose(fd);
fd = SocketCreate();
}
- protected void implConfigureBlocking(boolean block)
+ protected void implConfigureBlocking (boolean blocking) throws IOException
{
- if (blocking == block)
- return;
+ if (this.blocking == blocking)
+ return;
}
- public boolean connect(SocketAddress remote)
- throws IOException
+ public boolean connect (SocketAddress remote) throws IOException
{
if (connected)
- {
- throw new AlreadyConnectedException();
- }
+ {
+ throw new AlreadyConnectedException ();
+ }
// ok, lets connect !
@@ -130,17 +129,17 @@ public class SocketChannelImpl extends SocketChannel
return blocking;
}
- public boolean finishConnect()
+ public boolean finishConnect ()
{
return false;
}
- public boolean isConnected()
+ public boolean isConnected ()
{
return connected;
}
- public boolean isConnectionPending()
+ public boolean isConnectionPending ()
{
if (blocking)
return true;
@@ -148,7 +147,7 @@ public class SocketChannelImpl extends SocketChannel
return false;
}
- public Socket socket()
+ public Socket socket ()
{
if (sock_object != null)
{
@@ -158,7 +157,7 @@ public class SocketChannelImpl extends SocketChannel
return sock_object;
}
- public int read(ByteBuffer dst)
+ public int read (ByteBuffer dst) throws IOException
{
int bytes = 0;
int len = 1024;
@@ -168,27 +167,29 @@ public class SocketChannelImpl extends SocketChannel
dst.put(b, 0, bytes);
if (bytes == 0)
- {
+ {
// we've hit eof ?
return -1;
- }
+ }
return bytes;
}
- public long read(ByteBuffer[] dsts, int offset, int length)
+ public long read (ByteBuffer[] dsts, int offset, int length)
+ throws IOException
{
long bytes = 0;
- for (int i=offset; i<length; i++)
- {
- bytes += read(dsts[i]);
- }
+ for (int i = offset; i < length; i++)
+ {
+ bytes += read (dsts [i]);
+ }
return bytes;
}
- public int write(ByteBuffer src)
+ public int write (ByteBuffer src)
+ throws IOException
{
int bytes = 0;
int len = src.position();
@@ -210,13 +211,14 @@ public class SocketChannelImpl extends SocketChannel
}
public long write (ByteBuffer[] srcs, int offset, int length)
+ throws IOException
{
long bytes = 0;
- for (int i=offset; i<length; i++)
- {
- bytes += write(srcs[i]);
- }
+ for (int i = offset; i < length; i++)
+ {
+ bytes += write (srcs [i]);
+ }
return bytes;
}
diff --git a/libjava/gnu/java/nio/natFileLockImpl.cc b/libjava/gnu/java/nio/natFileLockImpl.cc
new file mode 100644
index 00000000000..19a3b83fde7
--- /dev/null
+++ b/libjava/gnu/java/nio/natFileLockImpl.cc
@@ -0,0 +1,25 @@
+// natFileLockImpl.cc
+
+/* Copyright (C) 2003 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 <jvm.h>
+#include <errno.h>
+
+#include <gnu/java/nio/FileLockImpl.h>
+#include <java/io/FileDescriptor.h>
+#include <java/io/IOException.h>
+
+void
+gnu::java::nio::FileLockImpl::releaseImpl ()
+{
+ throw new ::java::io::IOException
+ (JvNewStringUTF ("releaseImpl not implemented"));
+}
OpenPOWER on IntegriCloud