Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 20865 invoked from network); 14 Aug 2006 19:37:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Aug 2006 19:37:33 -0000 Received: (qmail 29919 invoked by uid 500); 14 Aug 2006 19:37:29 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 29880 invoked by uid 500); 14 Aug 2006 19:37:29 -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 29869 invoked by uid 99); 14 Aug 2006 19:37:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Aug 2006 12:37:29 -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; Mon, 14 Aug 2006 12:37:28 -0700 Received: (qmail 4764 invoked from network); 14 Aug 2006 19:37:04 -0000 Received: from ool-43560edb.dyn.optonline.net (HELO ?192.168.1.101?) (geir@67.86.14.219) by vdmx01.ivresearch.net with SMTP; 14 Aug 2006 19:37:04 -0000 Message-ID: <44E0D0E2.1040607@pobox.com> Date: Mon, 14 Aug 2006 15:37:06 -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> <12385bbd0608120255g4b377ac2pa38b06d937d9cc88@mail.gmail.com> <44E0A13A.20803@pobox.com> <200608142301.13632.gshimansky@gmail.com> In-Reply-To: <200608142301.13632.gshimansky@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 Gregory Shimansky wrote: > On Monday 14 August 2006 20:13 Geir Magnusson Jr wrote: >> Ivan Volosyuk wrote: >>> It looks like that it is possible to get zero bytes even at the very >>> end of array. IMHO the order of boundary checks makes sense here. >> This is an interesting problem. The JNI spec is clear that we should >> throw an exception when one of the indexes isn't valid, and start == >> size is arguably not valid, as Gregory points out. >> >> So I think the JNI impl is right for now (but I want to test w/ the JNI >> impl in RI....) > > I've written a test [1] myself and cannot say I completely understand the > result. With length = 0 RI 1.5 allows calling to GetArrayRegion with > start equal to array length but throws AIOOBE if start is greater than array > length. That makes sense to me, only because I am thinking of j.i.OutputStream's write([], int, int) method, which does state that it's ok if start + len == arraylen... I'm sure if we thought about it, we'd figure out that it lends itself nicely to some common loop idiom. I suspect it will be some end case when some read returns an empty buffer, so write(buf, 0, 0) works without a check, or some situation where there's some post decrement leading you to write(buf, length, len) where the len was calculated from (buf.length - length) or something. Now, that isn't what the JNI spec says, but it seems like the JNI spec was written in a hurry... :) > > I am unsure if we want to allow this compatibility and a reason to allow it. > When length is 0 the application still gets nothing except for clear > exception status. There is no value in allowing this call except for allowing > software which has a bug in it to work. On the other hand allowing start == > length to pass violates the spec IMHO. > > I think it is better if software which uses this undocumented feature was > fixed instead of introducing this workaround, so if others agree I think > HARMONY-1156 could be closed. Well, I don't feel strongly either way, but am uncomfortable with the inconsistency. The JNI docs seem pretty sparse, and clearly some thought went into allowing : write( buff, buff.length, 0) geir --------------------------------------------------------------------- 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