This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: some patches for 1.3 compatibility
Quoth Bryce McKinlay on Friday, 30 March:
:
: Thank you. In order to accept a patch of this size, we will need a copyright assignment to be completed
: and filed with the FSF. See: http://gcc.gnu.org/contribute.html
You're very welcome.
I'm surprised at the rigamarole, but I would like to contribute bug
fixes -- mostly compiler stuff. (I'm using gcj to port an app to
native on Linux and Win32, and encountering some bugs which I don't
want to work around -- mostly compiler stuff.) Thus I am quite
willing to jump through a few lawyerly hoops.
Please do send me the forms mentioned in those pages, which I cannot
access directly. (And why not, I might ask? It would encourage
contributors if they could file the required forms via the web -- and
at least U.S. contributors, where digital signatures are binding,
could close the whole loop in a matter of minutes.)
I see you need ChangeLog entries. Here's one for this patch:
J2SE 1.3 compatibility enhancements:
* libjava/java/io/*InputStream.java
add EOF marker to support use with sockets and Socket.shutdownInput()
* libjava/io/RandomAccessFile.java:
add method setLength
* libjava/java/net/Socket.java
add methods shutdownInput, shutdownOutput
* libjava/java/net/URL.java
add methods getPath, getQuery
: It would conserve a few bytes to use a bitmask here instead of boolean flags.
Okay, there's a new version of the PlainSocketImpl.java unified diff attached.
: Where does all this EOF stuff come from? It is not present in the J2SE 1.3 documentation from Sun:
It's all to support Socket.shutdownInput() and
Socket.shutdownOutput(): Clients using the result of
Socket.getInputStream() which call shutdownInput() get EOF semantics
on the InputStream immediately thereafter in the 1.3 JDK, according to
my test cases. It could be done more elegantly I think, but this way
one avoids adding a new implementation class, and the issue is small
enough so that it's really down in the noise.
Index: libjava/java/net/PlainSocketImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/PlainSocketImpl.java,v
retrieving revision 1.8
diff -u -r1.8 PlainSocketImpl.java
--- PlainSocketImpl.java 2000/12/08 10:28:32 1.8
+++ PlainSocketImpl.java 2001/03/30 06:47:48
@@ -35,6 +35,11 @@
_Jv_SO_SNDBUF_ = SocketOptions.SO_SNDBUF,
_Jv_SO_RCVBUF_ = SocketOptions.SO_RCVBUF;
+ private static final int SHUTDOWN_INPUT = 1;
+ private static final int SHUTDOWN_OUTPUT = 2;
+
+ private int shutdown_mask = 0 ;
+
int fnum = -1;
// This value is set/read by setOption/getOption.
@@ -73,6 +78,8 @@
protected InputStream getInputStream() throws IOException
{
// FIXME: TODO - Implement class SocketInputStream timeouts in read();
+ if (shutdown_mask & SHUTDOWN_INPUT != 0)
+ throw new IOException("Socket input stream is shut down");
if (in == null)
in = new FileInputStream (fd);
return in;
@@ -80,6 +87,8 @@
protected OutputStream getOutputStream() throws IOException
{
+ if (shutdown_mask & SHUTDOWN_OUTPUT != 0)
+ throw new IOException("Socket output stream is shut down");
if (out == null)
out = new FileOutputStream (fd);
return out;
@@ -95,4 +104,21 @@
if (fd.valid())
fd.close();
}
+
+ protected void shutdownInput() throws IOException
+ {
+ if (fd.valid())
+ fd.shutdownInput();
+ if (in != null)
+ in.setEOF();
+ shutdown_mask = shutdown_mask | SHUTDOWN_INPUT;
+ }
+
+ protected void shutdownOutput() throws IOException
+ {
+ if (fd.valid())
+ fd.shutdownOutput();
+ shutdown_mask = shutdown_mask | SHUTDOWN_OUTPUT;
+ }
+
}