This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
please disregard my earlier patches
- From: Tony Kimball <alk at pobox dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Thu, 4 Jul 2002 02:37:46 -0500
- Subject: please disregard my earlier patches
- Reply-to: alk at pobox dot com
I apologize for any inconvenience caused by my systematic error
in creating the diffs provided a few hours ago. They were between
the wrong code bases. I have since validated the following diffs
against a linux->mingw32 cross, as a sanity check on the win32 code.
This consolidates all of the patches provided earlier. This time
it really is a diff against the current HEAD:
Index: include/win32.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/include/win32.h,v
retrieving revision 1.8
diff -c -2 -r1.8 win32.h
*** include/win32.h 24 Apr 2002 01:33:19 -0000 1.8
--- include/win32.h 4 Jul 2002 07:26:23 -0000
***************
*** 16,19 ****
--- 16,20 ----
#undef __INSIDE_CYGWIN__
+ #include <io.h>
#include <winsock.h>
#include <gcj/cni.h>
Index: java/io/FileDescriptor.java
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/io/FileDescriptor.java,v
retrieving revision 1.9
diff -c -2 -r1.9 FileDescriptor.java
*** java/io/FileDescriptor.java 6 Mar 2002 22:37:26 -0000 1.9
--- java/io/FileDescriptor.java 4 Jul 2002 07:26:24 -0000
***************
*** 66,69 ****
--- 66,72 ----
throws IOException, NullPointerException, IndexOutOfBoundsException;
native void close () throws IOException;
+ native void shutdownInput () throws IOException;
+ native void shutdownOutput () throws IOException;
+ native void setLength (long pos) throws IOException;
// EOF_TRUNC is true if a request to seek past the end of file
// should actually stop at the end of file. If false, then a seek
Index: java/io/RandomAccessFile.java
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/io/RandomAccessFile.java,v
retrieving revision 1.6
diff -c -2 -r1.6 RandomAccessFile.java
*** java/io/RandomAccessFile.java 2 Aug 2001 23:46:39 -0000 1.6
--- java/io/RandomAccessFile.java 4 Jul 2002 07:26:24 -0000
***************
*** 41,44 ****
--- 41,50 ----
}
+ public void setLength (long pos) throws IOException
+ {
+ fd.setLength(pos);
+ return;
+ }
+
public long length () throws IOException
{
Index: java/io/natFileDescriptorEcos.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/io/natFileDescriptorEcos.cc,v
retrieving revision 1.8
diff -c -2 -r1.8 natFileDescriptorEcos.cc
*** java/io/natFileDescriptorEcos.cc 6 Mar 2002 23:23:34 -0000 1.8
--- java/io/natFileDescriptorEcos.cc 4 Jul 2002 07:26:24 -0000
***************
*** 96,99 ****
--- 96,114 ----
}
+ void
+ java::io::FileDescriptor::shutdownInput (void)
+ {
+ }
+
+ void
+ java::io::FileDescriptor::shutdownOutput (void)
+ {
+ }
+
+ void
+ java::io::FileDescriptor::setLength (void)
+ {
+ }
+
jint
java::io::FileDescriptor::seek (jlong pos, jint whence, jboolean)
Index: java/io/natFileDescriptorPosix.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/io/natFileDescriptorPosix.cc,v
retrieving revision 1.19
diff -c -2 -r1.19 natFileDescriptorPosix.cc
*** java/io/natFileDescriptorPosix.cc 10 Mar 2002 17:59:23 -0000 1.19
--- java/io/natFileDescriptorPosix.cc 4 Jul 2002 07:26:24 -0000
***************
*** 18,21 ****
--- 18,23 ----
#include <sys/stat.h>
#include <sys/param.h>
+ #include <sys/socket.h>
+ #include <fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
***************
*** 188,191 ****
--- 190,237 ----
if (::close (save))
throw new IOException (JvNewStringLatin1 (strerror (errno)));
+ }
+
+ void
+ java::io::FileDescriptor::shutdownInput (void)
+ {
+ if (::shutdown(fd,0))
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+ }
+
+ void
+ java::io::FileDescriptor::shutdownOutput (void)
+ {
+ if (::shutdown(fd,1))
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+ }
+
+ void
+ java::io::FileDescriptor::setLength (jlong pos)
+ {
+ struct stat sb;
+ off_t orig;
+
+ if (::fstat (fd, &sb))
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+
+ if ((jlong)sb.st_size == pos)
+ return;
+
+ orig = ::lseek(fd, (off_t) 0, SEEK_CUR);
+ if (orig == -1)
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+
+ if ((jlong)sb.st_size < pos) {
+ if (::lseek(fd, (off_t)pos, SEEK_SET) == -1)
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+ if (::lseek(fd, orig, SEEK_SET) == -1)
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+ return;
+ }
+
+ if (::ftruncate (fd, (off_t) pos))
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
+
+ return;
}
Index: java/io/natFileDescriptorWin32.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/io/natFileDescriptorWin32.cc,v
retrieving revision 1.9
diff -c -2 -r1.9 natFileDescriptorWin32.cc
*** java/io/natFileDescriptorWin32.cc 6 Jun 2002 20:39:37 -0000 1.9
--- java/io/natFileDescriptorWin32.cc 4 Jul 2002 07:26:26 -0000
***************
*** 187,190 ****
--- 187,250 ----
}
+ void
+ java::io::FileDescriptor::shutdownInput (void)
+ {
+ if (shutdown((SOCKET)fd,SD_RECEIVE) != 0)
+ throw new IOException (JvNewStringLatin1 (winerr ()));
+ }
+
+ void
+ java::io::FileDescriptor::shutdownOutput (void)
+ {
+ if (shutdown((SOCKET)fd,SD_SEND) != 0)
+ throw new IOException (JvNewStringLatin1 (winerr ()));
+ }
+
+ void
+ java::io::FileDescriptor::setLength(jlong pos)
+ {
+ LONG liOrigFilePointer;
+ LONG liNewFilePointer;
+ LONG liEndFilePointer;
+
+ // get the original file pointer
+ if (SetFilePointer((HANDLE)fd, (LONG)0, &liOrigFilePointer, FILE_CURRENT) != (BOOL)0
+ && (GetLastError() != NO_ERROR))
+ throw new IOException (JvNewStringLatin1 (winerr ()));
+
+ // get the length of the file
+ if (SetFilePointer((HANDLE)fd, (LONG)0, &liEndFilePointer, FILE_END) != (BOOL)0
+ && (GetLastError() != NO_ERROR))
+ throw new IOException (JvNewStringLatin1 (winerr ()));
+
+ if ((jlong)liEndFilePointer == pos) {
+ // restore the file pointer
+ if (liOrigFilePointer != liEndFilePointer) {
+ if (SetFilePointer((HANDLE)fd, liOrigFilePointer, &liNewFilePointer, FILE_BEGIN) != (BOOL)0
+ && (GetLastError() != NO_ERROR))
+ throw new IOException (JvNewStringLatin1 (winerr ()));
+ }
+ return;
+ }
+
+ // seek to the new end of file
+ if (SetFilePointer((HANDLE)fd, (LONG)pos, &liNewFilePointer, FILE_BEGIN) != (BOOL)0
+ && (GetLastError() != NO_ERROR))
+ throw new IOException (JvNewStringLatin1 (winerr ()));
+
+ // truncate the file at this point
+ if (SetEndOfFile((HANDLE)fd) != (BOOL)0 && (GetLastError() != NO_ERROR))
+ throw new IOException (JvNewStringLatin1 (winerr ()));
+
+ if (liOrigFilePointer < liNewFilePointer) {
+ // restore the file pointer
+ if (SetFilePointer((HANDLE)fd, liOrigFilePointer, &liNewFilePointer, FILE_BEGIN) != (BOOL)0
+ && (GetLastError() != NO_ERROR))
+ throw new IOException (JvNewStringLatin1 (winerr ()));
+ }
+
+ return;
+ }
+
jint
java::io::FileDescriptor::seek (jlong pos, jint whence, jboolean eof_trunc)
Index: java/lang/natRuntime.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/lang/natRuntime.cc,v
retrieving revision 1.23
diff -c -2 -r1.23 natRuntime.cc
*** java/lang/natRuntime.cc 14 May 2002 05:29:30 -0000 1.23
--- java/lang/natRuntime.cc 4 Jul 2002 07:26:27 -0000
***************
*** 576,580 ****
#ifdef WIN32
sb->append (JvNewStringLatin1 ("dll"));
! else
sb->append (JvNewStringLatin1 ("so"));
#endif
--- 576,580 ----
#ifdef WIN32
sb->append (JvNewStringLatin1 ("dll"));
! #else
sb->append (JvNewStringLatin1 ("so"));
#endif
Index: java/net/DatagramSocket.java
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/net/DatagramSocket.java,v
retrieving revision 1.10
diff -c -2 -r1.10 DatagramSocket.java
*** java/net/DatagramSocket.java 13 Jan 2002 11:59:37 -0000 1.10
--- java/net/DatagramSocket.java 4 Jul 2002 07:26:28 -0000
***************
*** 26,29 ****
--- 26,31 ----
{
DatagramSocketImpl impl;
+ InetAddress remoteAddr = null;
+ int remotePort = -1;
public DatagramSocket() throws SocketException
***************
*** 129,136 ****
public synchronized void receive(DatagramPacket p) throws IOException
{
! SecurityManager s = System.getSecurityManager();
! if (s != null)
! s.checkAccept(p.getAddress().getHostAddress(), p.getPort());
!
impl.receive(p);
}
--- 131,142 ----
public synchronized void receive(DatagramPacket p) throws IOException
{
! if (p == null) {
! SecurityManager s = System.getSecurityManager();
! if (s != null)
! s.checkAccept(p.getAddress().getHostAddress(), p.getPort());
! } else if ((p.getPort() != remotePort || !p.getAddress().equals(remoteAddr))) {
! throw new IllegalArgumentException("Inconsistent packet address for connection to "
! +remoteAddr+" port "+remotePort);
! }
impl.receive(p);
}
***************
*** 139,144 ****
{
// JDK1.2: Don't do security checks if socket is connected; see jdk1.2 api.
! SecurityManager s = System.getSecurityManager();
! if (s != null)
{
InetAddress addr = p.getAddress();
--- 145,151 ----
{
// JDK1.2: Don't do security checks if socket is connected; see jdk1.2 api.
! if (p == null) {
! SecurityManager s = System.getSecurityManager();
! if (s != null)
{
InetAddress addr = p.getAddress();
***************
*** 146,152 ****
s.checkMulticast(addr);
else
! s.checkConnect(addr.getHostAddress(), p.getPort());
}
!
// FIXME: if this is a subclass of MulticastSocket, use getTTL for TTL val.
impl.send(p);
--- 153,162 ----
s.checkMulticast(addr);
else
! s.checkConnect(addr.getHostAddress(), p.getPort());
}
! } else if ((p.getPort() != remotePort || !p.getAddress().equals(remoteAddr))) {
! throw new IllegalArgumentException("Inconsistent packet address for connection to "
! +remoteAddr+" port "+remotePort);
! }
// FIXME: if this is a subclass of MulticastSocket, use getTTL for TTL val.
impl.send(p);
***************
*** 161,193 ****
}
! // JDK1.2
! // public void connect(InetAddress address, int port)
! // {
! // }
!
! // JDK1.2
! // public void disconnect()
! // {
! // }
!
! // JDK1.2
! // public InetAddress getInetAddress()
! // {
! // }
!
! // JDK1.2
! // public int getPort()
! // {
! // }
!
! /**
! * This method returns the value of the system level socket option
! * SO_RCVBUF, which is used by the operating system to tune buffer
! * sizes for data transfers.
! *
! * @return The receive buffer size.
! *
! * @exception SocketException If an error occurs.
! *
* @since 1.2
*/
--- 171,221 ----
}
! public void connect(InetAddress address, int port) {
! synchronized (this) {
! SecurityManager s = System.getSecurityManager();
! if (s != null)
! {
! if (address.isMulticastAddress())
! s.checkMulticast(address);
! else
! s.checkConnect(address.getHostAddress(), port);
!
! remoteAddr = address;
! remotePort = port;
! if (remotePort < -1 || remotePort > 65535) {
! throw new IllegalArgumentException("bad remote parameters for local port "+
! impl.localPort);
! }
! }
! }
! }
!
! public void disconnect()
! {
! synchronized (this) {
! remotePort = -1;
! remoteAddr = null;
! }
! }
!
! public InetAddress getInetAddress()
! {
! return remoteAddr;
! }
!
! public int getPort()
! {
! return remotePort;
! }
!
! /**
! * This method returns the value of the system level socket option
! SO_RCVBUF, which is used by the operating system to tune buffer
! * sizes for data transfers.
! *
! @return The receive buffer size.
! *
! * @exception SocketException If an error occurs.
! *
* @since 1.2
*/
Index: java/net/URL.java
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/net/URL.java,v
retrieving revision 1.10
diff -c -2 -r1.10 URL.java
*** java/net/URL.java 23 Feb 2002 00:15:48 -0000 1.10
--- java/net/URL.java 4 Jul 2002 07:26:29 -0000
***************
*** 32,35 ****
--- 32,37 ----
private int port = -1; // Initialize for constructor using context.
private String file;
+ private String query = null;
+ private String path;
private String ref;
private int hashCode = 0;
***************
*** 94,97 ****
--- 96,111 ----
this.ref = file.substring(hashAt + 1);
}
+
+ int queryAt = file.lastIndexOf('?');
+ if (queryAt < 0)
+ {
+ this.path = file;
+ }
+ else
+ {
+ this.path = file.substring(0, queryAt);
+ this.query = file.substring(++queryAt);
+ }
+
hashCode = hashCode(); // Used for serialization.
}
***************
*** 187,190 ****
--- 201,215 ----
ref = spec.substring(hashAt + 1);
+ int queryAt = file.lastIndexOf('?');
+ if (queryAt < 0)
+ {
+ this.path = file;
+ }
+ else
+ {
+ this.path = file.substring(0, queryAt);
+ this.query = file.substring(++queryAt);
+ }
+
hashCode = hashCode(); // Used for serialization.
}
***************
*** 222,227 ****
public String getPath()
{
! int quest = file.indexOf('?');
! return quest < 0 ? file : file.substring(0, quest);
}
--- 247,256 ----
public String getPath()
{
! return path;
! }
!
! public String getQuery()
! {
! return query;
}
Index: java/net/natPlainDatagramSocketImpl.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/net/natPlainDatagramSocketImpl.cc,v
retrieving revision 1.39
diff -c -2 -r1.39 natPlainDatagramSocketImpl.cc
*** java/net/natPlainDatagramSocketImpl.cc 25 Jun 2002 05:29:22 -0000 1.39
--- java/net/natPlainDatagramSocketImpl.cc 4 Jul 2002 07:26:29 -0000
***************
*** 12,15 ****
--- 12,16 ----
#ifdef WIN32
+ #define NATIVE_CLOSE(s) closesocket(s);
#include <errno.h>
#include <string.h>
***************
*** 17,28 ****
#define ENOPROTOOPT 109
#endif
-
- static inline int
- close(int s)
- {
- return closesocket(s);
- }
-
#else /* WIN32 */
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
--- 18,23 ----
#define ENOPROTOOPT 109
#endif
#else /* WIN32 */
+ #define NATIVE_CLOSE(s) close(s);
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
***************
*** 304,308 ****
// The method isn't declared to throw anything, so we disregard
// the return value.
! ::close (fnum);
fnum = -1;
timeout = 0;
--- 299,303 ----
// The method isn't declared to throw anything, so we disregard
// the return value.
! (void)NATIVE_CLOSE(fnum);
fnum = -1;
timeout = 0;
***************
*** 411,414 ****
--- 406,410 ----
java::net::PlainDatagramSocketImpl::setTimeToLive (jint ttl)
{
+ #ifdef IP_MULTICAST_TTL
// Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
char val = (char) ttl;
***************
*** 419,422 ****
--- 415,421 ----
char* strerr = strerror (errno);
throw new java::io::IOException (JvNewStringUTF (strerr));
+ #else
+ throw new java::io::IOException (JvNewStringUTF ("IP_MULTICAST_TTL unimplemented"));
+ #endif
}
***************
*** 424,427 ****
--- 423,427 ----
java::net::PlainDatagramSocketImpl::getTimeToLive ()
{
+ #ifdef IP_MULTICAST_TTL
// Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
char val;
***************
*** 432,435 ****
--- 432,438 ----
char* strerr = strerror (errno);
throw new java::io::IOException (JvNewStringUTF (strerr));
+ #else
+ throw new java::io::IOException (JvNewStringUTF ("IP_MULTICAST_TTL unimplemented"));
+ #endif
}
***************
*** 559,562 ****
--- 562,566 ----
const char *ptr;
+ #ifdef IP_MULTICAST_IF
haddress = ((java::net::InetAddress *) value)->addr;
bytes = elements (haddress);
***************
*** 584,588 ****
throw
new java::net::SocketException (JvNewStringUTF ("invalid length"));
!
if (::setsockopt (fnum, level, opname, ptr, len) != 0)
goto error;
--- 588,595 ----
throw
new java::net::SocketException (JvNewStringUTF ("invalid length"));
! #else
! throw
! new java::net::SocketException (JvNewStringUTF ("IP_MULTICAST_IF unimplemented"));
! #endif
if (::setsockopt (fnum, level, opname, ptr, len) != 0)
goto error;
***************
*** 675,678 ****
--- 682,686 ----
char *bytes;
+ #ifdef IP_MULTICAST_IF
inaddr_len = sizeof(inaddr);
if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_IF, (char *) &inaddr,
***************
*** 683,686 ****
--- 691,698 ----
return java::net::InetAddress::getByName (JvNewStringLatin1 (bytes));
+ #else
+ throw new java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF unimplemented"));
+ #endif
#else
throw new java::net::SocketException (
Index: java/net/natPlainSocketImpl.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/net/natPlainSocketImpl.cc,v
retrieving revision 1.42
diff -c -2 -r1.42 natPlainSocketImpl.cc
*** java/net/natPlainSocketImpl.cc 18 Jun 2002 16:25:00 -0000 1.42
--- java/net/natPlainSocketImpl.cc 4 Jul 2002 07:26:31 -0000
***************
*** 12,15 ****
--- 12,16 ----
#ifndef DISABLE_JAVA_NET
#ifdef WIN32
+ #define NATIVE_CLOSE(s) closesocket(s);
#include <windows.h>
#include <winsock.h>
***************
*** 21,31 ****
#undef FIONREAD
- // These functions make the Win32 socket API look more POSIXy
- static inline int
- close(int s)
- {
- return closesocket(s);
- }
-
static inline int
write(int s, void *buf, int len)
--- 22,25 ----
***************
*** 47,51 ****
#endif
#else /* WIN32 */
!
#ifdef HAVE_SYS_IOCTL_H
#define BSD_COMP /* Get FIONREAD on Solaris2. */
--- 41,45 ----
#endif
#else /* WIN32 */
! #define NATIVE_CLOSE(s) close(s);
#ifdef HAVE_SYS_IOCTL_H
#define BSD_COMP /* Get FIONREAD on Solaris2. */