Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 32119 invoked from network); 11 Aug 2006 12:58:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Aug 2006 12:58:53 -0000 Received: (qmail 89097 invoked by uid 500); 11 Aug 2006 12:58:50 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 89055 invoked by uid 500); 11 Aug 2006 12:58:50 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 89044 invoked by uid 99); 11 Aug 2006 12:58:50 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Aug 2006 05:58:50 -0700 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 64.74.244.70 is neither permitted nor denied by domain of geir@pobox.com) Received: from [64.74.244.70] (HELO smtp.ivresearch.com) (64.74.244.70) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 11 Aug 2006 05:58:49 -0700 Received: (qmail 28583 invoked from network); 11 Aug 2006 12:58:27 -0000 Received: from 24-53-91-85.clspco.adelphia.net (HELO ?192.168.1.123?) (geir@24.53.91.85) by vdmx01.ivresearch.net with SMTP; 11 Aug 2006 12:58:27 -0000 Message-ID: <44DC7EF4.8010406@pobox.com> Date: Fri, 11 Aug 2006 08:58:28 -0400 From: Geir Magnusson Jr Reply-To: geir@pobox.com User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: [DRLVM][JNI]GetByteArrayRegion differs from RI (was Re: Exceptions found while running servlet...) References: <11f7653a0608092244y74fd7187rbfdba08bec29bea5@mail.gmail.com> <44DAEBEA.9000806@gmail.com> <44DAEEF5.5040204@gmail.com> <44DAFF7A.2060204@gmail.com> <44DB1E27.6070808@gmail.com> <44DBED16.5030400@gmail.com> In-Reply-To: <44DBED16.5030400@gmail.com> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I think we should just fix it in DRLVM, although performance-wise, wouldn't also fixing in Java make sense too? As Tim said, raise a JIRA. geir Jimmy, Jing Lv wrote: > Hi, > > As discussed in the former thread, I find that a JNI of DRLVM > (GetByteArrayRegion) differs from RI in passing parameter > (byte[count],count,0). RI (and J9 VM) returns immediately but DRLVM > throws an ArrayIndexOutOfBoundsException. > IMHO, it is better to improve here, make it follow RI, as JNI is > also a part of API, and users may use it. So if no objections, shall I > or someone raise a JIRA for this? > > I don't know if Martin is urgent in using Harmony in Winstone > servlet engine (Martin, can you read this?), so shall I work around in > java code before we have conclusion? > > Any comments/suggestions from DRLVM guys? Thanks! > > > Jimmy, Jing Lv wrote: >> Jimmy, Jing Lv wrote: >>> >>> >>> 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 >> /* 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) >> >> > > --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org For additional commands, e-mail: harmony-dev-help@incubator.apache.org