harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geir Magnusson Jr <g...@pobox.com>
Subject [drlvm][jni] Summary of Re: [DRLVM][JNI]GetByteArrayRegion differs from RI (was Re: Exceptions found while running servlet...)
Date Tue, 15 Aug 2006 17:21:56 GMT
So to summarize so we can close this.  I assume that we all agree that
the JNI spec is lacking, and that we should follow the RI as it's
reasonable behavior.

Gregory has added a patch to HARMONY-1156 and I'm going to accept and
apply that.

If there is any opposition, please speak now.

geir

Ivan Volosyuk wrote:
> +1 for the following check:
> 
>> a) offset is negative or
>> b) len is negative or
>> c) off + len > buff.length
> 
> -- 
> Ivan
> 
> On 8/14/06, Geir Magnusson Jr <geir@pobox.com> 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....)
>>
>> As for classlibrary :
>>
>> I was testing with the RI vi java.io.OutputStream#write(buff[], offset,
>> len), and the RI is clearly broken as it doesn't throw an NPE when [] is
>> null.
>>
>> However, strictly speaking, an IndexOOBE is thrown when :
>>
>> a) offset is negative or
>> b) len is negative or
>> c) off + len > buff.length
>>
>> So in the case of
>>
>>    write( byte[count], count, 0);
>>
>> for any value of count >= 0, then none of the conditions are true, and
>> it should simply [quickly] return.
>>
>> Therefore, I'll start a new thread re refining OutputStream to match
>> those rules, and then go on to test the JNI impl of the RI.
>>
>> geir
>>
>> > --
>> > Ivan
>> >
>> > On 8/11/06, Gregory Shimansky <gshimansky@gmail.com> wrote:
>> >> 2006/8/11, Jimmy, Jing Lv <firepure@gmail.com>:
>> >> >
>> >> > 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!
>> >> >
>> >>
>> >> I didn't really understand the condition when vm throws AIOBE. Do you
>> >> pass
>> >> start parameter count for the array of count length? But in this
>> case the
>> >> start points to the element right after the array end. And spec [1]
>> >> explicitly states that this function should throw AIOBE in this
>> case. Is
>> >> there something I don't understand?
>> >>
>> >> [1]
>> >>
>> http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/functions.html#wp6212
> 
> ---------------------------------------------------------------------
> 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
> 
> 
> 

---------------------------------------------------------------------
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


Mime
View raw message