+2002-01-18 Tom Tromey <tromey@redhat.com>
+
+ * java/net/natPlainSocketImpl.cc: Include
+ IllegalArgumentException.h.
+ (_Jv_recv): New template function.
+ (BooleanClass): Removed.
+ (read): Use _Jv_recv.
+ (setOption): Use Boolean::class$. Throw exception if object is
+ not Boolean or Integer.
+
2002-01-17 Tom Tromey <tromey@redhat.com>
* java/awt/MenuComponent.java: Merged with Classpath.
-/* Copyright (C) 1998, 1999, 2000 , 2002 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation
This file is part of libgcj.
#undef accept
#endif
+// A wrapper for recv so we don't have to do configure tests.
+template <typename T_fd, typename T_buf, typename T_len, typename T_flags>
+static inline int
+_Jv_recv (int (*recv_func) (T_fd s, T_buf buf, T_len len, T_flags flags),
+ int s, void *buf, size_t len, int flags)
+{
+ return recv_func ((T_fd) s, (T_buf) buf, (T_len) len, (T_flags) flags);
+}
+
#include <gcj/cni.h>
#include <gcj/javaprims.h>
#include <java/io/IOException.h>
#include <java/lang/Thread.h>
#include <java/lang/NullPointerException.h>
#include <java/lang/ArrayIndexOutOfBoundsException.h>
-
-#define BooleanClass java::lang::Boolean::class$
+#include <java/lang/IllegalArgumentException.h>
#ifdef DISABLE_JAVA_NET
}
}
// Read the socket.
- int r = ::recv (fnum, bytes, count, 0);
+ int r = _Jv_recv (::recv, fnum, (void *) bytes, count, 0);
if (r == 0)
return -1;
if (java::lang::Thread::interrupted())
int val;
socklen_t val_len = sizeof (val);
- if (_Jv_IsInstanceOf (value, &BooleanClass))
+ if (_Jv_IsInstanceOf (value, &java::lang::Boolean::class$))
{
java::lang::Boolean *boolobj =
static_cast<java::lang::Boolean *> (value);
val = 0;
}
}
- else // assume value is an Integer
+ else if (_Jv_IsInstanceOf (value, &java::lang::Integer::class$))
{
java::lang::Integer *intobj =
static_cast<java::lang::Integer *> (value);
val = (int) intobj->intValue();
}
+ else
+ {
+ throw new java::lang::IllegalArgumentException (JvNewStringLatin1 ("`value' must be Boolean or Integer"));
+ }
switch (optID)
{