Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 5791 invoked from network); 14 Aug 2006 19:01:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Aug 2006 19:01:44 -0000 Received: (qmail 45611 invoked by uid 500); 14 Aug 2006 19:01:38 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 45573 invoked by uid 500); 14 Aug 2006 19:01:38 -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 45475 invoked by uid 99); 14 Aug 2006 19:01:38 -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:01:37 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of gshimansky@gmail.com designates 64.233.182.187 as permitted sender) Received: from [64.233.182.187] (HELO nf-out-0910.google.com) (64.233.182.187) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Aug 2006 12:01:36 -0700 Received: by nf-out-0910.google.com with SMTP id c29so45456nfb for ; Mon, 14 Aug 2006 12:01:15 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:reply-to:to:subject:date:user-agent:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; b=aUbsUSfb8K5w/gHaoX3CXmvYlJ9adelgLjNp/vXhPfO6uE7OskSZmtuaNi9HHB7hCCELXSKVMCwhOIqOHhHN8kM9Q/AeAEI62pEbOj9Lu6lQ5VLXUYHt+l3j/kwy3ePL7uEGtkmEdq50h82BnqUnFO6lPe8EdEV+CS725EikWRI= Received: by 10.49.19.18 with SMTP id w18mr260310nfi; Mon, 14 Aug 2006 12:01:15 -0700 (PDT) Received: from ppp85-140-187-31.pppoe.mtu-net.ru ( [85.140.187.31]) by mx.gmail.com with ESMTP id a24sm256190nfc.2006.08.14.12.01.13; Mon, 14 Aug 2006 12:01:14 -0700 (PDT) From: Gregory Shimansky Reply-To: harmony-dev@incubator.apache.org To: harmony-dev@incubator.apache.org Subject: Re: [DRLVM][JNI]GetByteArrayRegion differs from RI (was Re: Exceptions found while running servlet...) Date: Mon, 14 Aug 2006 23:01:13 +0400 User-Agent: KMail/1.9.1 References: <11f7653a0608092244y74fd7187rbfdba08bec29bea5@mail.gmail.com> <12385bbd0608120255g4b377ac2pa38b06d937d9cc88@mail.gmail.com> <44E0A13A.20803@pobox.com> In-Reply-To: <44E0A13A.20803@pobox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200608142301.13632.gshimansky@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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. 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. [1] public class AIOOBE { static { System.loadLibrary("AIOOBE"); } private native void nativeMethod(int array[], int start); public static void main(String args[]) { int array[] = new int[10]; System.out.println("Calling with length 10"); (new AIOOBE()).nativeMethod(array, 10); System.out.println("Calling with length 11"); (new AIOOBE()).nativeMethod(array, 11); System.out.println("Calling with length 100"); (new AIOOBE()).nativeMethod(array, 100); } } /* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class AIOOBE */ #ifndef _Included_AIOOBE #define _Included_AIOOBE #ifdef __cplusplus extern "C" { #endif /* * Class: AIOOBE * Method: nativeMethod * Signature: ([II)V */ JNIEXPORT void JNICALL Java_AIOOBE_nativeMethod (JNIEnv *jenv, jobject thisObject, jintArray array, jint start) { int buffer[1024]; (*jenv)->GetIntArrayRegion(jenv, array, start, 0, buffer); } #ifdef __cplusplus } #endif #endif -- Gregory Shimansky, Intel Middleware Products Division --------------------------------------------------------------------- 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