Inexplicable Parameter-Passing Phenomena w/MinGW GCJ
Mohan Embar
gnustuff@thisiscool.com
Wed Sep 10 07:06:00 GMT 2003
Hi People,
I'm slowly losing my mind, so I'm going to babble
incoherently before going to bed.
I am further testing Michael's networking patch
which no one has approved yet and which seems okay
to me:
http://gcc.gnu.org/ml/java-patches/2003-q3/msg00535.html
Through some strange phenomenon which appears to
have nothing to do with the patch, gnu.java.net.DatagramSocket
has this call in setSoTimeout():
---------------------------------------8<----------------------------------
public synchronized void setSoTimeout(int timeout) throws SocketException
{
if (timeout < 0)
throw new IllegalArgumentException("Invalid timeout: " + timeout);
impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
}
---------------------------------------8<----------------------------------
...where impl.setOption is a CNI-native method in natPlainDatagramSocketImplWin32.cc:
which I've enhanced with MessageBox statements which should serve as breadcrumbs
which follow my downward spiral towards insanity:
---------------------------------------8<----------------------------------
gnu::java::net::PlainDatagramSocketImpl::setOption (jint optID,
::java::lang::Object *value)
{
int val = 0;
socklen_t val_len = sizeof (val);
MessageBox(NULL, "setOption", "We are here.", MB_OK);
if (fnum < 0)
throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed"));
if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$))
{
MessageBox(NULL, "setOption", "1111", MB_OK);
::java::lang::Boolean *boolobj =
static_cast< ::java::lang::Boolean *> (value);
val = boolobj->booleanValue() ? 1 : 0;
}
else if (_Jv_IsInstanceOf (value, &::java::lang::Integer::class$))
{
MessageBox(NULL, "setOption", "2222", MB_OK);
::java::lang::Integer *intobj =
static_cast< ::java::lang::Integer *> (value);
val = (int) intobj->intValue();
}
else
{
MessageBox(NULL, "setOption", "3333", MB_OK);
}
// Else assume value to be an InetAddress for use with IP_MULTICAST_IF.
MessageBox(NULL, "setOption", "4444", MB_OK);
fflush(stdout);
---------------------------------------8<----------------------------------
Here is the call in my test program which calls DatagramSocket.setOption():
---------------------------------------8<----------------------------------
if (m_nTimeoutMSecs > 0)
{
System.out.println("Setting timeout to "+m_nTimeoutMSecs);
skt.setSoTimeout(m_nTimeoutMSecs);
System.out.println("Timeout: "+skt.getSoTimeout());
}
---------------------------------------8<----------------------------------
When the above skt.getSoTimeout() call is uncommented, the MessageBoxes appear,
but I get a "3333", which means that new Integer(timeout) in DatagramSocket
was not identified as either a java.lang.Boolean or a java.lang.Integer
in natPlainDatagramSocketImplWin32.cc/setOption(). (At one point in time,
I printed value->getClass()->getName() and I got "java.lang.Class".)
When the above skt.getTimeout() call (which happens AFTER the skt.setSoTimeout()
call and should therefore have no effect on it) is commented out, no
message boxes appear.
I know I need to troubleshoot this and document this much further, but what
I'm looking for is any sort of "aha" here. Keep in mind that this is a
statically linked libgcj.
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
More information about the Java
mailing list