Index: native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c =================================================================== RCS file: /cvsroot/classpath/classpath/native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c,v retrieving revision 1.4 diff -u -r1.4 gnu_java_net_PlainDatagramSocketImpl.c --- native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c 29 Mar 2004 07:07:39 -0000 1.4 +++ native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c 7 May 2004 14:13:31 -0000 @@ -163,6 +163,7 @@ #ifndef WITHOUT_NETWORK unsigned int addr, port, maxlen, offset, bytes_read; jclass cls, addr_cls; + jfieldID fid; jmethodID mid; jarray arr; unsigned char octets[4]; @@ -207,7 +208,7 @@ } /* Now get the offset from the packet */ - mid = (*env)->GetMethodID(env, cls, "getOffset", "()I"); + mid = (*env)->GetMethodID(env, cls, "getOffset", "()I"); if (mid == NULL) { JCL_ThrowException(env, IO_EXCEPTION, "Internal error: getOffset"); @@ -224,7 +225,19 @@ DBG("PlainDatagramSocketImpl.receive(): Got the offset\n"); /* Now get the maximal available length from the packet */ - maxlen = (*env)->GetArrayLength(env,arr) - offset; + fid = (*env)->GetFieldID(env, cls, "maxlen", "I"); + if (mid == NULL) + { + JCL_ThrowException(env, IO_EXCEPTION, "Internal error: maxlen"); + return; + } + + maxlen = (*env)->GetIntField (env, packet, fid); + if ((*env)->ExceptionOccurred(env)) + { + JCL_ThrowException(env, IO_EXCEPTION, "Internal error: call length"); + return; + } /* Receive the packet */ /* should we try some sort of validation on the length? */ @@ -318,17 +331,17 @@ DBG("PlainDatagramSocketImpl.receive(): Stored the port\n"); /* Store back the length */ - mid = (*env)->GetMethodID(env, cls, "setLength", "(I)V"); - if (mid == NULL) + fid = (*env)->GetFieldID(env, cls, "length", "I"); + if (fid == NULL) { - JCL_ThrowException(env, IO_EXCEPTION, "Internal error: setLength"); + JCL_ThrowException(env, IO_EXCEPTION, "Internal error: length"); return; } - (*env)->CallVoidMethod(env, packet, mid, bytes_read); + (*env)->SetIntField (env, packet, fid, bytes_read); if ((*env)->ExceptionOccurred(env)) { - JCL_ThrowException(env, IO_EXCEPTION, "Internal error: call setLength"); + JCL_ThrowException(env, IO_EXCEPTION, "Internal error: call length"); return; }