Hello, Rick Knowles, the author of Winstone servlet engine, replied to my email with this information:
"Martin, I think this is because winstone will sometimes do a outputstream.write(arr, 0, 0), because the content length is actually zero. It's likely that this is swallowed invisibly by IBM JRE, but not by harmony. Probably something for both sides to fix - me, by removing the call since it's not necessary, and harmony by allowing such writes. Thanks, Rick" Hope it helps. Regards, Martin On 8/10/06, Jimmy, Jing Lv <[EMAIL PROTECTED]> wrote:
Jimmy, Jing Lv wrote: > <snip> > > I do some further study and test then, and find the problem was not so > easy. > > Alex and I are correct that "offset <= buffer.length" here is wrong, but > the next "count <= buffer.length - offset" seems has proved its > correctness. > > I have a test[1], try to write(new byte[count],count, 0) to a > SocketOutputStream, the test passes quietly. I do this test on WinXp > Sp2, the latest Harmony workspace, with J9 VM5. > > I believe the ArrayIndexOutOfBoundsException is throw out when it try to > get byte array in the native (GetByteArrayRegion), which is a JNI > method. I guess there may be some difference between VMs. > > Martin, are you using DRLVM? Can someone using DRLVM (or other VMs) run > the test below on DRLVM for me? Thanks! > > [1] > public void test_socketOutputStream() throws Exception { > ServerSocket ss = new ServerSocket(0); > Socket sock = new Socket(); > sock.connect(new InetSocketAddress > (InetAddress.getLocalHost(),ss.getLocalPort())); > ss.accept(); > OutputStream os = sock.getOutputStream(); > os.write(new byte[0], 0, 0); // passes here > os.write(new byte[512], 512, 0); // passes here > } > Hi, At last I have test[1] JNI method(GetByteArrayRegion) of RI (before dinner, very hungry... :) ) The result is that, RI return successfully if the given offset equals length of the byte array, and the given count is zero. Thus IMHO it is better to improve DRLVM to follow RI, as JNI methods are also API methods, users may use it. Shall we raise a JIRA for DRLVM? Any comments/suggestions from DRLVM guys? Thanks! Time for dinner! :D [1] test.java -------------- class test { static{ System.loadLibrary("testjni"); } private native void testjni(byte[] bs); public void usejni(){ testjni(new byte[512]); } public static void main(String args[]){ new test().usejni(); } } --------------- test.h --------------- /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class test */ #ifndef _Included_test #define _Included_test #ifdef __cplusplus extern "C" { #endif /* * Class: test * Method: testjni * Signature: ([B)V */ JNIEXPORT void JNICALL Java_test_testjni (JNIEnv *, jobject, jbyteArray); #ifdef __cplusplus } #endif #endif ------------------ test.c ------------------ #include "test.h" JNIEXPORT void JNICALL Java_test_testjni (JNIEnv * env, jobject obj,jbyteArray array){ jbyte* buf = (jbyte*)malloc(sizeof(jbyte)*512); (*env)->GetByteArrayRegion(env,array,512, 0, buf); } (magic number 512 can be any integer, including zero) <snip> -- Best Regards! Jimmy, Jing Lv China Software Development Lab, IBM --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Dinamica - RADical J2EE framework open source, easy and powerful http://www.martincordova.com --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]