PatchSet 4239 
Date: 2003/12/27 21:15:47
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Partial synchronization with classpath/libgcj (nio). JVMPI/XPROF disable on Cygwin

Members: 
        ChangeLog:1.1828->1.1829 
        configure:1.270->1.271 
        configure.in:1.235->1.236 
        config/i386/cygwin32/md.h:1.3->1.4 
        kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.104->1.105 
        libraries/javalib/Makefile.am:1.150->1.151 
        libraries/javalib/Makefile.in:1.202->1.203 
        libraries/javalib/essential.files:1.33->1.34 
        libraries/javalib/gnu/java/lang/reflect/TypeSignature.java:1.3->1.4 
        libraries/javalib/gnu/java/net/DNSJavaInetAddressImpl.java:1.1->1.2 
        libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.3->1.4 
        libraries/javalib/gnu/java/nio/ChannelInputStream.java:INITIAL->1.1 
        libraries/javalib/gnu/java/nio/ChannelOutputStream.java:INITIAL->1.1 
        libraries/javalib/gnu/java/nio/InputStreamChannel.java:INITIAL->1.1 
        libraries/javalib/gnu/java/nio/OutputStreamChannel.java:INITIAL->1.1 
        libraries/javalib/gnu/java/nio/SelectorImpl.java:1.6->1.7 
        libraries/javalib/gnu/java/rmi/server/RMIVoidValue.java:1.1->1.2 
        libraries/javalib/gnu/java/rmi/server/UnicastRemoteCall.java:1.2->1.3 
        libraries/javalib/gnu/java/rmi/server/UnicastServerRef.java:1.2->1.3 
        libraries/javalib/java/io/FilePermission.java:1.5->1.6 
        libraries/javalib/java/net/DatagramSocket.java:1.19->1.20 
        libraries/javalib/java/net/ServerSocket.java:1.20->1.21 
        libraries/javalib/java/net/URL.java:1.35->1.36 
        libraries/javalib/java/net/URLStreamHandler.java:1.13->1.14 
        libraries/javalib/java/nio/ByteOrder.java:1.4->1.5 
        libraries/javalib/java/nio/DirectByteBufferImpl.java:1.3->1.4 
        libraries/javalib/java/nio/channels/Channels.java:1.3->1.4 
        libraries/javalib/java/nio/channels/FileChannelImpl.java:1.3->1.4 
        
libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java:1.3->1.4 
        libraries/javalib/javax/naming/directory/Attribute.java:1.3->1.4 
        libraries/javalib/javax/naming/directory/Attributes.java:1.2->1.3 
        libraries/javalib/javax/naming/directory/DirContext.java:1.2->1.3 
        libraries/javalib/javax/naming/directory/InitialDirContext.java:1.1->1.2 
        libraries/javalib/javax/naming/directory/SearchResult.java:1.1->1.2 
        libraries/javalib/javax/naming/event/EventContext.java:1.2->1.3 
        libraries/javalib/javax/naming/event/EventDirContext.java:1.2->1.3 
        libraries/javalib/javax/naming/event/NamingEvent.java:1.1->1.2 
        libraries/javalib/javax/naming/event/NamingExceptionEvent.java:1.1->1.2 
        libraries/javalib/javax/naming/ldap/ControlFactory.java:1.1->1.2 
        libraries/javalib/javax/naming/ldap/ExtendedRequest.java:1.2->1.3 
        libraries/javalib/javax/naming/ldap/HasControls.java:1.2->1.3 
        libraries/javalib/javax/naming/ldap/InitialLdapContext.java:1.1->1.2 
        libraries/javalib/javax/naming/ldap/LdapContext.java:1.2->1.3 
        libraries/javalib/javax/naming/ldap/LdapReferralException.java:1.1->1.2 
        libraries/javalib/javax/naming/ldap/UnsolicitedNotification.java:1.2->1.3 
        
libraries/javalib/javax/naming/ldap/UnsolicitedNotificationListener.java:1.2->1.3 
        libraries/javalib/javax/naming/spi/DirObjectFactory.java:1.2->1.3 
        libraries/javalib/javax/naming/spi/DirStateFactory.java:1.2->1.3 
        libraries/javalib/javax/naming/spi/DirectoryManager.java:1.1->1.2 
        libraries/javalib/javax/naming/spi/NamingManager.java:1.5->1.6 
        libraries/javalib/javax/naming/spi/ObjectFactoryBuilder.java:1.2->1.3 
        libraries/javalib/javax/naming/spi/ResolveResult.java:1.1->1.2 
        libraries/javalib/javax/naming/spi/Resolver.java:1.2->1.3 
        libraries/javalib/javax/naming/spi/StateFactory.java:1.2->1.3 
        libraries/javalib/pure-java/math/java/math/BigDecimal.java:1.3->1.4 
        libraries/javalib/pure-java/math/java/math/BigInteger.java:1.2->1.3 
        test/regression/URLTest.java:1.4->1.5 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1828 kaffe/ChangeLog:1.1829
--- kaffe/ChangeLog:1.1828      Fri Dec 26 18:51:20 2003
+++ kaffe/ChangeLog     Sat Dec 27 21:15:47 2003
@@ -1,3 +1,73 @@
+2003-12-27  Guilhem Lavaux <[EMAIL PROTECTED]>
+
+       * configure, libraries/javalib/Makefile.am,
+       libraries/javalib/Makefile.in: Regenerated.
+
+       * configure.in, config/i386/cygwin32/md.h,
+       kaffe/kaffevm/systems/unix-jthreads/jthread.c:
+       Disable JVMPI and XPROF when the system is a cygwin.
+
+       * libraries/javalib/essential.files: Added missing classes in NIO.
+
+       * test/regression/URLTest.java: Changed regression test. Checking here is
+       too strict and so the message could change.
+       
+       * libraries/javalib/gnu/java/lang/reflect/TypeSignature.java,
+       libraries/javalib/gnu/java/rmi/server/RMIVoidValue.java,
+       libraries/javalib/gnu/java/rmi/server/UnicastRemoteCall.java,
+       libraries/javalib/gnu/java/rmi/server/UnicastServerRef.java,
+       libraries/javalib/java/io/FilePermission.java,
+       libraries/javalib/java/net/DatagramSocket.java,
+       libraries/javalib/java/net/ServerSocket.java,
+       libraries/javalib/java/net/URL.java,
+       libraries/javalib/java/net/URLStreamHandler.java,
+       libraries/javalib/java/nio/ByteOrder.java,
+       libraries/javalib/java/nio/DirectByteBufferImpl.java,
+       libraries/javalib/java/nio/channels/Channels.java,
+       libraries/javalib/java/nio/channels/FileChannelImpl.java,
+       libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java,
+       libraries/javalib/javax/naming/directory/Attribute.java,
+       libraries/javalib/javax/naming/directory/Attributes.java,
+       libraries/javalib/javax/naming/directory/DirContext.java,
+       libraries/javalib/javax/naming/directory/InitialDirContext.java,
+       libraries/javalib/javax/naming/directory/SearchResult.java,
+       libraries/javalib/javax/naming/event/EventContext.java,
+       libraries/javalib/javax/naming/event/EventDirContext.java,
+       libraries/javalib/javax/naming/event/NamingEvent.java,
+       libraries/javalib/javax/naming/event/NamingExceptionEvent.java,
+       libraries/javalib/javax/naming/ldap/ControlFactory.java,
+       libraries/javalib/javax/naming/ldap/ExtendedRequest.java,
+       libraries/javalib/javax/naming/ldap/HasControls.java,
+       libraries/javalib/javax/naming/ldap/InitialLdapContext.java,
+       libraries/javalib/javax/naming/ldap/LdapContext.java,
+       libraries/javalib/javax/naming/ldap/LdapReferralException.java,
+       libraries/javalib/javax/naming/ldap/UnsolicitedNotification.java,
+       libraries/javalib/javax/naming/ldap/UnsolicitedNotificationListener.java,
+       libraries/javalib/javax/naming/spi/DirObjectFactory.java,
+       libraries/javalib/javax/naming/spi/DirStateFactory.java,
+       libraries/javalib/javax/naming/spi/DirectoryManager.java,
+       libraries/javalib/javax/naming/spi/NamingManager.java,
+       libraries/javalib/javax/naming/spi/ObjectFactoryBuilder.java,
+       libraries/javalib/javax/naming/spi/ResolveResult.java,
+       libraries/javalib/javax/naming/spi/Resolver.java,
+       libraries/javalib/javax/naming/spi/StateFactory.java,
+       libraries/javalib/pure-java/math/java/math/BigDecimal.java,
+       libraries/javalib/pure-java/math/java/math/BigInteger.java:
+       Resynchronized with Classpath.
+
+       * libraries/javalib/java/nio/ByteOrder.java,
+       libraries/javalib/java/nio/DirectByteBufferImpl.java,
+       libraries/javalib/java/nio/channels/Channels.java,
+       libraries/javalib/java/nio/channels/FileChannelImpl.java,
+       libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java,
+       libraries/javalib/gnu/java/net/protocol/http/Connection.java,
+       libraries/javalib/gnu/java/nio/ChannelInputStream.java,
+       libraries/javalib/gnu/java/nio/ChannelOutputStream.java,
+       libraries/javalib/gnu/java/nio/InputStreamChannel.java,
+       libraries/javalib/gnu/java/nio/OutputStreamChannel.java,
+       libraries/javalib/gnu/java/nio/SelectorImpl.java:
+       Merged from GCJ/libjava.
+       
 2003-12-26  Guilhem Lavaux <[EMAIL PROTECTED]>
 
        * libraries/javalib/kjc.jar: Regenerated KJC to
Index: kaffe/configure
diff -u kaffe/configure:1.270 kaffe/configure:1.271
--- kaffe/configure:1.270       Wed Dec 24 19:06:50 2003
+++ kaffe/configure     Sat Dec 27 21:15:48 2003
@@ -19288,9 +19288,14 @@
 fi
 
 
+NOSIGCONTEXT=false
+
 case $Khost_os in
 win32*)
        SYSTEM=win32 ;;
+cygwin*)
+       SYSTEM=unix;
+       NOSIGCONTEXT=true;;
 *)
        SYSTEM=unix ;;
 esac
@@ -19468,11 +19473,15 @@
 case "$enable_jvmpi" in
 "") ;;
 no) ;;
-*)
+*) if test "x$NOSIGCONTEXT" = "xtrue"; then
+       echo "JVMPI does not support Cygwin"
+   else
+
 cat >>confdefs.h <<\_ACEOF
 #define ENABLE_JVMPI 1
 _ACEOF
-;;
+
+   fi;;
 esac
 
 
@@ -19516,6 +19525,11 @@
   enableval="$enable_xprofiling"
 
 fi;
+if test "x$NOSIGCONTEXT" = "xtrue"; then
+  echo "XProfiling does not support Cygwin"
+  enable_xprofiling=no
+fi
+
 case "$enable_xprofiling" in
 "") xprofiling=no ;;
 no) xprofiling=no ;;
Index: kaffe/configure.in
diff -u kaffe/configure.in:1.235 kaffe/configure.in:1.236
--- kaffe/configure.in:1.235    Wed Dec 24 19:06:54 2003
+++ kaffe/configure.in  Sat Dec 27 21:15:52 2003
@@ -159,9 +159,14 @@
 dnl -------------------------------------------------------------------------
 
 dnl What kind of system are we using?
+NOSIGCONTEXT=false
+
 case $Khost_os in
 win32*)
        SYSTEM=win32 ;;
+cygwin*)
+       SYSTEM=unix;
+       NOSIGCONTEXT=true;;
 *)
        SYSTEM=unix ;;
 esac
@@ -330,7 +335,11 @@
 case "$enable_jvmpi" in
 "") ;;
 no) ;;
-*) AC_DEFINE(ENABLE_JVMPI, 1, [JVM Profiling Interface]);;
+*) if test "x$NOSIGCONTEXT" = "xtrue"; then
+       echo "JVMPI does not support Cygwin"
+   else
+       AC_DEFINE(ENABLE_JVMPI, 1, [JVM Profiling Interface])
+   fi;;
 esac
 
 AM_CONDITIONAL(ENABLE_JVMPI, test x"$enable_jvmpi" = x"yes")
@@ -354,6 +363,11 @@
 need_libxprof=no
 
 AC_ARG_ENABLE(xprofiling,[  --enable-xprofiling     Enable profiling for C and jitted 
code])
+if test "x$NOSIGCONTEXT" = "xtrue"; then
+  echo "XProfiling does not support Cygwin"
+  enable_xprofiling=no
+fi
+
 case "$enable_xprofiling" in
 "") xprofiling=no ;;
 no) xprofiling=no ;;
Index: kaffe/config/i386/cygwin32/md.h
diff -u kaffe/config/i386/cygwin32/md.h:1.3 kaffe/config/i386/cygwin32/md.h:1.4
--- kaffe/config/i386/cygwin32/md.h:1.3 Thu Dec 11 17:56:21 2003
+++ kaffe/config/i386/cygwin32/md.h     Sat Dec 27 21:15:54 2003
@@ -26,7 +26,10 @@
 #undef SP_OFFSET
 #define        SP_OFFSET       7
 
-#error Signal handlers are not supported on CygWin32.
+#define SIGNAL_ARGS(sig, sc) int sig
+#define SIGNAL_CONTEXT_POINTER(scp) int scp
+#define GET_SIGNAL_CONTEXT_POINTER(sc) (NULL)
+#define SIGNAL_PC(scp) (0)
 
 #if defined(TRANSLATOR)
 #include "jit-md.h"
Index: kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c
diff -u kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.104 
kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.105
--- kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.104   Fri Dec 19 18:36:00 
2003
+++ kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c Sat Dec 27 21:15:54 2003
@@ -417,7 +417,9 @@
 {
        if( currentJThread->status != THREAD_SUSPENDED )
        {
+#ifdef ENABLE_JVMPI
                EXCEPTIONFRAME(jthread_current()->localData.topFrame, sc);
+#endif
        }
        
        /*
Index: kaffe/libraries/javalib/Makefile.am
diff -u kaffe/libraries/javalib/Makefile.am:1.150 
kaffe/libraries/javalib/Makefile.am:1.151
--- kaffe/libraries/javalib/Makefile.am:1.150   Tue Dec 23 20:18:42 2003
+++ kaffe/libraries/javalib/Makefile.am Sat Dec 27 21:15:55 2003
@@ -389,13 +389,17 @@
        gnu/java/net/protocol/jar/Connection.java \
        gnu/java/net/protocol/jar/Handler.java
 gnu_java_nio_SRCS = \
+       gnu/java/nio/ChannelInputStream.java \
+       gnu/java/nio/ChannelOutputStream.java \
        gnu/java/nio/DatagramChannelImpl.java \
        gnu/java/nio/DatagramChannelSelectionKey.java \
        gnu/java/nio/FileLockImpl.java \
+       gnu/java/nio/InputStreamChannel.java \
        gnu/java/nio/NIOConstants.java \
        gnu/java/nio/NIODatagramSocket.java \
        gnu/java/nio/NIOServerSocket.java \
        gnu/java/nio/NIOSocket.java \
+       gnu/java/nio/OutputStreamChannel.java \
        gnu/java/nio/PipeImpl.java \
        gnu/java/nio/SelectionKeyImpl.java \
        gnu/java/nio/SelectorImpl.java \
Index: kaffe/libraries/javalib/Makefile.in
diff -u kaffe/libraries/javalib/Makefile.in:1.202 
kaffe/libraries/javalib/Makefile.in:1.203
--- kaffe/libraries/javalib/Makefile.in:1.202   Wed Dec 24 19:07:23 2003
+++ kaffe/libraries/javalib/Makefile.in Sat Dec 27 21:15:55 2003
@@ -662,13 +662,17 @@
        gnu/java/net/protocol/jar/Handler.java
 
 gnu_java_nio_SRCS = \
+       gnu/java/nio/ChannelInputStream.java \
+       gnu/java/nio/ChannelOutputStream.java \
        gnu/java/nio/DatagramChannelImpl.java \
        gnu/java/nio/DatagramChannelSelectionKey.java \
        gnu/java/nio/FileLockImpl.java \
+       gnu/java/nio/InputStreamChannel.java \
        gnu/java/nio/NIOConstants.java \
        gnu/java/nio/NIODatagramSocket.java \
        gnu/java/nio/NIOServerSocket.java \
        gnu/java/nio/NIOSocket.java \
+       gnu/java/nio/OutputStreamChannel.java \
        gnu/java/nio/PipeImpl.java \
        gnu/java/nio/SelectionKeyImpl.java \
        gnu/java/nio/SelectorImpl.java \
Index: kaffe/libraries/javalib/essential.files
diff -u kaffe/libraries/javalib/essential.files:1.33 
kaffe/libraries/javalib/essential.files:1.34
--- kaffe/libraries/javalib/essential.files:1.33        Mon Nov  3 04:25:49 2003
+++ kaffe/libraries/javalib/essential.files     Sat Dec 27 21:15:55 2003
@@ -20,13 +20,17 @@
 gnu/java/nio/charset/UTF_16.java
 gnu/java/nio/charset/UTF_16LE.java
 gnu/java/nio/charset/UTF_8.java
+gnu/java/nio/ChannelInputStream.java
+gnu/java/nio/ChannelOutputStream.java
 gnu/java/nio/DatagramChannelImpl.java
 gnu/java/nio/DatagramChannelSelectionKey.java
 gnu/java/nio/FileLockImpl.java
+gnu/java/nio/InputStreamChannel.java
 gnu/java/nio/NIOConstants.java
 gnu/java/nio/NIODatagramSocket.java
 gnu/java/nio/NIOServerSocket.java
 gnu/java/nio/NIOSocket.java
+gnu/java/nio/OutputStreamChannel.java
 gnu/java/nio/PipeImpl.java
 gnu/java/nio/SelectionKeyImpl.java
 gnu/java/nio/SelectorImpl.java
Index: kaffe/libraries/javalib/gnu/java/lang/reflect/TypeSignature.java
diff -u kaffe/libraries/javalib/gnu/java/lang/reflect/TypeSignature.java:1.3 
kaffe/libraries/javalib/gnu/java/lang/reflect/TypeSignature.java:1.4
--- kaffe/libraries/javalib/gnu/java/lang/reflect/TypeSignature.java:1.3        Wed 
Dec  3 19:57:15 2003
+++ kaffe/libraries/javalib/gnu/java/lang/reflect/TypeSignature.java    Sat Dec 27 
21:15:56 2003
@@ -173,7 +173,8 @@
    * @see #getEncodingOfClass(Class, boolean)
    * @see #getClassForEncoding(String, boolean)
    */
-   public static Class getClassForEncoding(String type_code, boolean descriptor, 
ClassLoader loader)
+  public static Class getClassForEncoding(String type_code, boolean descriptor,
+                                         ClassLoader loader)
     throws ClassNotFoundException
   {
     if (descriptor)
Index: kaffe/libraries/javalib/gnu/java/net/DNSJavaInetAddressImpl.java
diff -u kaffe/libraries/javalib/gnu/java/net/DNSJavaInetAddressImpl.java:1.1 
kaffe/libraries/javalib/gnu/java/net/DNSJavaInetAddressImpl.java:1.2
--- kaffe/libraries/javalib/gnu/java/net/DNSJavaInetAddressImpl.java:1.1        Tue 
Dec 23 20:18:54 2003
+++ kaffe/libraries/javalib/gnu/java/net/DNSJavaInetAddressImpl.java    Sat Dec 27 
21:15:56 2003
@@ -52,7 +52,6 @@
 import org.xbill.DNS.DClass;
 import org.xbill.DNS.ReverseMap;
 
-/* This class is just a forward to native implementation. */
 public class DNSJavaInetAddressImpl implements InetAddressImpl
 {
   static private Resolver resolver = null;
@@ -60,7 +59,6 @@
   public String getHostByAddr(byte[] ip)
     throws UnknownHostException
   {
-    
     if (resolver == null)
       resolver = new ExtendedResolver();
 
Index: kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java
diff -u kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.3 
kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.4
--- kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.3      Tue 
Dec 23 20:18:54 2003
+++ kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java  Sat Dec 27 
21:15:57 2003
@@ -119,11 +119,6 @@
   private ByteArrayOutputStream bufferedOutputStream;
 
   /**
-   * The PrintWriter for this connection (used internally)
-   */
-  private PrintWriter outputWriter;
-
-  /**
    * This is the object that holds the header field information
    */
   private HeaderFieldHelper headers = new HeaderFieldHelper();
@@ -164,13 +159,11 @@
        socket = new Socket(url.getHost(), port);
       }
 
-    if (doInput)
-      inputStream = new DataInputStream
-       (new BufferedInputStream (socket.getInputStream()));
+    inputStream =
+      new DataInputStream(new BufferedInputStream(socket.getInputStream()));
 
     outputStream = new BufferedOutputStream (socket.getOutputStream());
     bufferedOutputStream = new ByteArrayOutputStream (256); //default is too small
-    outputWriter = new PrintWriter (new OutputStreamWriter (outputStream, "8859_1")); 
 
     sendRequest();
     receiveReply();
@@ -202,36 +195,30 @@
    */
   void sendRequest() throws IOException
   {
+    // Create PrintWriter for easier sending of headers.
+    PrintWriter outputWriter =
+      new PrintWriter(new OutputStreamWriter(outputStream, "8859_1")); 
+    
     // Send request including any request properties that were set.
     outputWriter.print (getRequestMethod() + " " + url.getFile()
                         + " HTTP/1.1\r\n");
 
     // Set additional HTTP headers.
     if (getRequestProperty ("Host") == null)
-      {
-        setRequestProperty ("Host", url.getHost());
-      }
+      setRequestProperty ("Host", url.getHost());
     
     if (getRequestProperty ("Connection") == null)
-      {
-        setRequestProperty ("Connection", "Close");
-      }
+      setRequestProperty ("Connection", "Close");
     
     if (getRequestProperty ("user-agent") == null)
-      {
-        setRequestProperty ("user-agent", "gnu-classpath/"
-                            + System.getProperty ("classpath.version"));
-      }
+      setRequestProperty ("user-agent", "gnu-classpath/"
+                          + System.getProperty ("classpath.version"));
     
     if (getRequestProperty ("accept") == null)
-      {
-        setRequestProperty ("accept", "*/*");
-      }
+      setRequestProperty ("accept", "*/*");
     
     if (getRequestProperty ("Content-type") == null)
-      {
-        setRequestProperty ("Content-type", "application/x-www-form-urlencoded");
-      }
+      setRequestProperty ("Content-type", "application/x-www-form-urlencoded");
 
     // Set correct content length.
     setRequestProperty ("Content-length", String.valueOf 
(bufferedOutputStream.size()));
@@ -257,7 +244,7 @@
   /**
    * Read HTTP reply from inputStream.
    */
-  void receiveReply() throws IOException
+  private void receiveReply() throws IOException
   {
     // Parse the reply
     String line = inputStream.readLine();
@@ -268,6 +255,8 @@
         || (line.length() < (idx + 6)))
       throw new IOException ("Server reply was unparseable: " + saveline);
 
+    headers.addHeaderField (null, line);
+
     line = line.substring (idx + 1);
     String code = line.substring (0, 3);
     
@@ -349,6 +338,59 @@
   }
 
   /**
+   * Return a boolean indicating whether or not this connection is
+   * going through a proxy
+   *
+   * @return true if using a proxy, false otherwise
+   */
+  public boolean usingProxy()
+  {
+    return proxyInUse;
+  }
+
+  /**
+   * Returns an InputStream for reading from this connection.  This stream
+   * will be "queued up" for reading just the contents of the requested file.
+   * Overrides URLConnection.getInputStream()
+   *
+   * @return An InputStream for this connection.
+   *
+   * @exception IOException If an error occurs
+   */
+  public InputStream getInputStream() throws IOException
+  {
+    if (!connected)
+      connect();
+
+    if (!doInput)
+      throw new ProtocolException("Can't open InputStream if doInput is false");
+    
+    return inputStream;
+  }
+
+  /**
+   * Returns on OutputStream for writing to this connection.
+   *
+   * @return An OutputStream for this connection.
+   *
+   * @exception IOException If an error occurs
+   */
+  public OutputStream getOutputStream() throws IOException
+  {
+    if (!doOutput)
+      throw new ProtocolException
+        ("Want output stream while haven't setDoOutput(true)");
+    
+    if (!method.equals ("POST")) //But we might support "PUT" in future
+      setRequestMethod ("POST");
+  
+    if (!connected)
+      connect();
+    
+    return bufferedOutputStream;
+  }
+
+  /**
    * Overrides java.net.HttpURLConnection.setRequestMethod() in order to
    * restrict the available methods to only those we support.
    *
@@ -368,34 +410,18 @@
       throw new ProtocolException ("Unsupported or unknown request method " +
                                    method);
   }
-  
-  /**
-   * Return a boolean indicating whether or not this connection is
-   * going through a proxy
-   *
-   * @return true if using a proxy, false otherwise
-   */
-  public boolean usingProxy()
-  {
-    return proxyInUse;
-  }
 
   /**
-   * This method returns the header field key at the specified numeric
+   * This method returns the header field value at the specified numeric
    * index.
    *
    * @param n The index into the header field array
    *
-   * @return The name of the header field key, or <code>null</code> if the
-   * specified index is not valid.
+   * @return The value of the specified header field, or <code>null</code>
+   * if the specified index is not valid.
    */
-  public String getHeaderFieldKey (int n)
+  public String getHeaderField(int n)
   {
-    if (n < 1)
-      return null;
-
-    n--;
-
     if (!connected)
       try
        {
@@ -406,24 +432,20 @@
          return null;
        }
 
-    return headers.getHeaderFieldKeyByIndex (n);
+    return headers.getHeaderFieldValueByIndex (n);
   }
 
   /**
-   * This method returns the header field value at the specified numeric
+   * This method returns the header field key at the specified numeric
    * index.
    *
    * @param n The index into the header field array
    *
-   * @return The value of the specified header field, or <code>null</code>
-   * if the specified index is not valid.
+   * @return The name of the header field key, or <code>null</code> if the
+   * specified index is not valid.
    */
-  public String getHeaderField (int n)
+  public String getHeaderFieldKey(int n)
   {
-    if (n < 1)
-      return null;
-
-    n--;
     if (!connected)
       try
        {
@@ -434,43 +456,6 @@
          return null;
        }
 
-    return headers.getHeaderFieldValueByIndex (n);
-  }
-
-  /**
-   * Returns an InputStream for reading from this connection.  This stream
-   * will be "queued up" for reading just the contents of the requested file.
-   * Overrides URLConnection.getInputStream()
-   *
-   * @return An InputStream for this connection.
-   *
-   * @exception IOException If an error occurs
-   */
-  public InputStream getInputStream() throws IOException
-  {
-    if(inputStream != null)
-      return inputStream;
-
-    if (!connected)
-      connect();
-
-    return inputStream;
-  }
-
-  public OutputStream getOutputStream() throws IOException
-  {
-    if (!doOutput)
-      throw new ProtocolException
-        ("Want output stream while haven't setDoOutput(true)");
-    
-    if (!method.equals ("POST")) //But we might support "PUT" in future
-      setRequestMethod ("POST");
-  
-    if (!connected)
-      connect();
-  
-    return bufferedOutputStream;
+    return headers.getHeaderFieldKeyByIndex (n);
   }
-
-
 }
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/nio/ChannelInputStream.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/nio/ChannelInputStream.java,v
VERS: 1.1
***************
--- /dev/null   Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/nio/ChannelInputStream.java        Sat Dec 27 
21:18:06 2003
@@ -0,0 +1,79 @@
+/* ChannelInputStream.java -- 
+   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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 gnu.java.nio;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.IllegalBlockingModeException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.SelectableChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class ChannelInputStream extends InputStream
+{
+  private ReadableByteChannel ch;
+  
+  public ChannelInputStream (ReadableByteChannel ch)
+  {
+    super();
+    
+    this.ch = ch;
+  }
+
+  public int read() throws IOException
+  {
+    if (ch instanceof SelectableChannel
+       && (! ((SelectableChannel) ch).isBlocking()))
+      throw new IllegalBlockingModeException();
+      
+    ByteBuffer buffer = ByteBuffer.allocate(1);
+    int result = ch.read(buffer);
+
+    if (result == -1)
+      return -1;
+
+    if (result == 0)
+      throw new IOException("Could not read from channel");
+
+     return buffer.get(0);
+  }
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/nio/ChannelOutputStream.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/nio/ChannelOutputStream.java,v
VERS: 1.1
***************
--- /dev/null   Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/nio/ChannelOutputStream.java       Sat Dec 27 
21:18:06 2003
@@ -0,0 +1,67 @@
+/* ChannelOutputStream.java -- 
+   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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 gnu.java.nio;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class ChannelOutputStream extends OutputStream
+{
+  private WritableByteChannel ch;
+  
+  public ChannelOutputStream (WritableByteChannel ch)
+  {
+    super();
+    
+    this.ch = ch;
+  }
+
+  public void write (int value) throws IOException
+  {
+    ByteBuffer buffer = ByteBuffer.allocate (1);
+    buffer.put ((byte) (value & 0xff));
+    buffer.flip();
+    ch.write (buffer);
+  }
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/nio/InputStreamChannel.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/nio/InputStreamChannel.java,v
VERS: 1.1
***************
--- /dev/null   Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/nio/InputStreamChannel.java        Sat Dec 27 
21:18:06 2003
@@ -0,0 +1,88 @@
+/* InputStreamChannel.java -- 
+   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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 gnu.java.nio;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.ReadableByteChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class InputStreamChannel implements ReadableByteChannel
+{
+  private boolean closed = false;
+  private InputStream in;
+  
+  public InputStreamChannel (InputStream in)
+  {
+    super();
+    this.in = in;
+  }
+
+  public void close() throws IOException
+  {
+    if (!closed)
+      {
+        in.close();
+        closed = true;
+      }
+  }
+
+  public boolean isOpen()
+  {
+    return !closed;
+  }
+
+  public int read (ByteBuffer dst) throws IOException
+  {
+    if (!isOpen())
+      throw new ClosedChannelException();
+    
+    byte[] buffer = new byte [dst.remaining()];
+    int readBytes = in.read (buffer);
+
+    if (readBytes > 0)
+      dst.put (buffer, 0, readBytes);
+
+    return readBytes;
+  }
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/nio/OutputStreamChannel.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/nio/OutputStreamChannel.java,v
VERS: 1.1
***************
--- /dev/null   Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/nio/OutputStreamChannel.java       Sat Dec 27 
21:18:06 2003
@@ -0,0 +1,87 @@
+/* OutputStreamChannel.java -- 
+   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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 gnu.java.nio;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.WritableByteChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class OutputStreamChannel implements WritableByteChannel
+{
+  private boolean closed = false;
+  private OutputStream out;
+  
+  public OutputStreamChannel (OutputStream out)
+  {
+    super();
+    
+    this.out = out;
+  }
+
+  public void close() throws IOException
+  {
+    if (!closed)
+      {
+        out.close();
+        closed = true;
+      }
+  }
+
+  public boolean isOpen()
+  {
+    return !closed;
+  }
+  
+  public int write (ByteBuffer src) throws IOException
+  {
+    if (!isOpen())
+      throw new ClosedChannelException();
+    
+    int len = src.remaining();
+    byte[] buffer = new byte [len];
+    src.get (buffer);
+    out.write (buffer);
+    return len;
+  }
+}
Index: kaffe/libraries/javalib/gnu/java/nio/SelectorImpl.java
diff -u kaffe/libraries/javalib/gnu/java/nio/SelectorImpl.java:1.6 
kaffe/libraries/javalib/gnu/java/nio/SelectorImpl.java:1.7
--- kaffe/libraries/javalib/gnu/java/nio/SelectorImpl.java:1.6  Tue Oct 28 12:29:38 
2003
+++ kaffe/libraries/javalib/gnu/java/nio/SelectorImpl.java      Sat Dec 27 21:15:57 
2003
@@ -65,12 +65,34 @@
   private Set keys;
   private Set selected;
 

*** Patch too long, truncated ***

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to