Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-12 Thread Richard Liang
Richard Liang wrote: Geir Magnusson Jr wrote: Richard Liang wrote: Geir Magnusson Jr wrote: Richard Liang wrote: For this case, I decide to follow useRadix(int radix). Please correct me if I'm wrong. Thanks a lot. Do you mean that you're going to follow the

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-09 Thread Richard Liang
Geir Magnusson Jr wrote: Richard Liang wrote: Geir Magnusson Jr wrote: Richard Liang wrote: For this case, I decide to follow useRadix(int radix). Please correct me if I'm wrong. Thanks a lot. Do you mean that you're going to follow the spec? If so, we

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-07 Thread Anton Luht
It seems like the RI is doing random crap, and it wouldn't be something that someone would depend on... can you imagine? Easily :) One more example: Pattern.compile((?![^\\xB5]), Pattern.CASE_INSENSITIVE); exposes implementation problems: java.lang.ArrayIndexOutOfBoundsException at

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-07 Thread Geir Magnusson Jr
Richard Liang wrote: Geir Magnusson Jr wrote: This is a great example. The last two aren't even legal exceptions for that method. It seems like the RI is doing random crap, and it wouldn't be something that someone would depend on... can you imagine? Thanks a lot, Geir. There

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-07 Thread Geir Magnusson Jr
Richard Liang wrote: For this case, I decide to follow useRadix(int radix). Please correct me if I'm wrong. Thanks a lot. Do you mean that you're going to follow the spec? If so, we should note that we're making a conscious decision to differ from the RI. geir

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-07 Thread Richard Liang
Geir Magnusson Jr wrote: Richard Liang wrote: For this case, I decide to follow useRadix(int radix). Please correct me if I'm wrong. Thanks a lot. Do you mean that you're going to follow the spec? If so, we should note that we're making a conscious decision to differ from the RI.

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-07 Thread Geir Magnusson Jr
Richard Liang wrote: Geir Magnusson Jr wrote: Richard Liang wrote: For this case, I decide to follow useRadix(int radix). Please correct me if I'm wrong. Thanks a lot. Do you mean that you're going to follow the spec? If so, we should note that we're making a conscious

[classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Richard Liang
Hello All, When I'm trying to implement Scanner.nextInt(int radix), I met a problem. As we all know, Character.MIN_RADIX equals 2 and Character.MAX_RADIX equals 36, so the parameter radix can not less than 2 or greater than 36, Otherwise that parameter is illegal. But on RI, when the

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Anton Avtamonov
Hi Richard, Very good example. You are right, spec says nothing about invalid radix processing for nextInt(). RI behavior just proves they have no guard check. However useRadix() produces IAE for the invalid radix and the sound of logic says that IAE is a proper reaction for wrong radix in any

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Richard Liang
Paulex Yang wrote: Richard Liang wrote: Hello All, When I'm trying to implement Scanner.nextInt(int radix), I met a problem. As we all know, Character.MIN_RADIX equals 2 and Character.MAX_RADIX equals 36, so the parameter radix can not less than 2 or greater than 36, Otherwise that

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Richard Liang
Anton Avtamonov wrote: Hi Richard, Very good example. You are right, spec says nothing about invalid radix processing for nextInt(). RI behavior just proves they have no guard check. However useRadix() produces IAE for the invalid radix and the sound of logic says that IAE is a proper

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Geir Magnusson Jr
This is a great example. The last two aren't even legal exceptions for that method. It seems like the RI is doing random crap, and it wouldn't be something that someone would depend on... can you imagine? try { Scanner.nextInt(foo); } catch {StringInxOutOfBndsEx bar) { ... real

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Chris Gray
On Thursday 06 July 2006 16:49, Geir Magnusson Jr wrote: This is a great example. The last two aren't even legal exceptions for that method. It seems like the RI is doing random crap, and it wouldn't be something that someone would depend on... can you imagine? I think we have to

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Richard Liang
Chris Gray wrote: On Thursday 06 July 2006 16:49, Geir Magnusson Jr wrote: This is a great example. The last two aren't even legal exceptions for that method. It seems like the RI is doing random crap, and it wouldn't be something that someone would depend on... can you imagine? I

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Paulex Yang
Richard Liang wrote: Paulex Yang wrote: Richard Liang wrote: Hello All, When I'm trying to implement Scanner.nextInt(int radix), I met a problem. As we all know, Character.MIN_RADIX equals 2 and Character.MAX_RADIX equals 36, so the parameter radix can not less than 2 or greater than

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Richard Liang
Geir Magnusson Jr wrote: This is a great example. The last two aren't even legal exceptions for that method. It seems like the RI is doing random crap, and it wouldn't be something that someone would depend on... can you imagine? Thanks a lot, Geir. There may be a great deal of these

Re: [classlib] Exception throwing compatibility: java.util.Scanner

2006-07-06 Thread Anton Avtamonov
On 7/7/06, Richard Liang [EMAIL PROTECTED] wrote: SNIP We may frequently encounter this confused situation, and I suggest we discuss the problems case by case if someone is not sure how to do. ;-) For this case, I decide to follow useRadix(int radix). Please correct me if I'm wrong. Thanks a

Re: [classlib] Exception-throwing compatibility question

2006-07-04 Thread Andrew Zhang
George, Totally agree with you. Shall we summarize and document the discuss to Harmony exception-thrown compatibility guideline? Thanks! On 6/30/06, George Harley [EMAIL PROTECTED] wrote: Mikhail Loenko wrote: For the example I've started this thread with it seems that complying the spec

Re: [classlib] Exception-throwing compatibility question

2006-07-04 Thread Boris Kuznetsov
So, we should always follow RI? Even when RI behavior is not consistent and contradicts the spec.? Here is one example: javax.crypto.EncryptedPrivateKeyInfo(algName, encryptedData) spec. states: NoSuchAlgorithmException - if the specified algName is not supported. For code: new

Re: [classlib] Exception-throwing compatibility question

2006-07-04 Thread Boris Kuznetsov
correction: RI throws NoSuchAlgorithmException for new EncryptedPrivateKeyInfo(0, new byte[598]); On 7/4/06, Boris Kuznetsov [EMAIL PROTECTED] wrote: So, we should always follow RI? Even when RI behavior is not consistent and contradicts the spec.? Here is one example:

Re: [classlib] Exception-throwing compatibility question

2006-07-04 Thread Geir Magnusson Jr
Boris Kuznetsov wrote: So, we should always follow RI? Even when RI behavior is not consistent and contradicts the spec.? I never think it's a case of always. I think it's a case of always discuss :) geir Here is one example: javax.crypto.EncryptedPrivateKeyInfo(algName,

Re: [classlib] Exception-throwing compatibility question

2006-07-03 Thread Tim Ellison
Mikhail Loenko wrote: For the example I've started this thread with it seems that complying the spec is more appropriate there. But probably there are other examples that caused that the doc was worded the given way George and Tim could you please comment? What is the concrete example?

Re: [classlib] Exception-throwing compatibility question

2006-07-03 Thread Anton Luht
Hello, There's one example that shows that not only code may contain bugs, but documentation also: 1.5.0 spec [1] says about java.io.BufferedWriter.write(String, int, int) If the value of the len parameter is negative then no characters are written. This is contrary to the specification of

Re: [classlib] Exception-throwing compatibility question

2006-07-03 Thread Chris Gray
In 1.4.2 it was a bug, but in 1.5.0 it's a feature. :-) What a difference a doc makes ... Chris On Monday 03 July 2006 14:12, Anton Luht wrote: Hello, There's one example that shows that not only code may contain bugs, but documentation also: 1.5.0 spec [1] says about

Re: [classlib] Exception-throwing compatibility question

2006-07-03 Thread Andrew Zhang
Maybe it's called javadoc bug or spec bug. :) On 7/3/06, Chris Gray [EMAIL PROTECTED] wrote: In 1.4.2 it was a bug, but in 1.5.0 it's a feature. :-) What a difference a doc makes ... Chris On Monday 03 July 2006 14:12, Anton Luht wrote: Hello, There's one example that shows that not only

Re: [classlib] Exception-throwing compatibility question

2006-07-03 Thread Chris Gray
On Monday 03 July 2006 14:33, Andrew Zhang wrote: Maybe it's called javadoc bug or spec bug. :) Looks to me very like oops, our implementation isn't according to spec, better change the spec. To be fair to Sun, fixing the implementation could have broken existing code (maybe it did, hence the

Re: [classlib] Exception-throwing compatibility question

2006-07-03 Thread Geir Magnusson Jr
I think that the details should be considered in this, but I'd rather us follow the RI (and log it as a difference from the spec) if we have some inkling that user code will be affected by it. geir Mikhail Loenko wrote: Do I undersyand correctly that even when spec says e.g. that Exception1

Re: [classlib] Exception-throwing compatibility question

2006-07-03 Thread Richard Liang
Hello George, Agree. We shall always following RI when throwing exception. But Harmony developer could discuss specific problems on mailing list if he/she feels uncomfortable. ;-) George Harley wrote: Mikhail Loenko wrote: For the example I've started this thread with it seems that

[classlib] Exception-throwing compatibility question

2006-06-30 Thread Mikhail Loenko
Do I undersyand correctly that even when spec says e.g. that Exception1 is thrown when parameter1 == 10 and RI throws Exception2 then we follow RI ? Thanks, Mikhail - Terms of use :

Re: [classlib] Exception-throwing compatibility question

2006-06-30 Thread Paulex Yang
Any relationship between Exception1 and Exception2? Mikhail Loenko wrote: Do I undersyand correctly that even when spec says e.g. that Exception1 is thrown when parameter1 == 10 and RI throws Exception2 then we follow RI ? Thanks, Mikhail

Re: [classlib] Exception-throwing compatibility question

2006-06-30 Thread Mikhail Loenko
No 2006/6/30, Paulex Yang [EMAIL PROTECTED]: Any relationship between Exception1 and Exception2? Mikhail Loenko wrote: Do I undersyand correctly that even when spec says e.g. that Exception1 is thrown when parameter1 == 10 and RI throws Exception2 then we follow RI ? Thanks, Mikhail

Re: [classlib] Exception-throwing compatibility question

2006-06-30 Thread Paulex Yang
So I think it is the Rule1 to follow spec if the behavior is clearly specified? Mikhail Loenko wrote: No 2006/6/30, Paulex Yang [EMAIL PROTECTED]: Any relationship between Exception1 and Exception2? Mikhail Loenko wrote: Do I undersyand correctly that even when spec says e.g. that

Re: [classlib] Exception-throwing compatibility question

2006-06-30 Thread Mikhail Loenko
But section Exception-throwing compatibility says that exceptions are different and we aim to be fully compartible with the RI by matching the exception characteristics of each method. 2006/6/30, Paulex Yang [EMAIL PROTECTED]: So I think it is the Rule1 to follow spec if the behavior is

Re: [classlib] Exception-throwing compatibility question

2006-06-30 Thread Anton Avtamonov
On 6/30/06, Mikhail Loenko [EMAIL PROTECTED] wrote: But section Exception-throwing compatibility says that exceptions are different and we aim to be fully compartible with the RI by matching the exception characteristics of each method. I believe that it is for However, in most cases the

Re: [classlib] Exception-throwing compatibility question

2006-06-30 Thread Paulex Yang
Anton Avtamonov wrote: On 6/30/06, Mikhail Loenko [EMAIL PROTECTED] wrote: But section Exception-throwing compatibility says that exceptions are different and we aim to be fully compartible with the RI by matching the exception characteristics of each method. I believe that it is for However,

Re: [classlib] Exception-throwing compatibility question

2006-06-30 Thread Mikhail Loenko
For the example I've started this thread with it seems that complying the spec is more appropriate there. But probably there are other examples that caused that the doc was worded the given way George and Tim could you please comment? Thanks, Mikhail 2006/6/30, Paulex Yang [EMAIL PROTECTED]:

Re: [classlib] Exception-throwing compatibility question

2006-06-30 Thread George Harley
Mikhail Loenko wrote: For the example I've started this thread with it seems that complying the spec is more appropriate there. But probably there are other examples that caused that the doc was worded the given way George and Tim could you please comment? Thanks, Mikhail Hi Mikhail, I love

Re: [classlib] Request for golden ticket to update String class (was: Re: [classlib] Exception throwing compatibility)

2006-05-14 Thread Ivan Volosyuk
I like this solution. If my opinion is counted: +1 from me. -- Ivan Intel Middleware Products Division 2006/5/14, Tim Ellison [EMAIL PROTECTED]: I agree with your analysis. +1 from me. Regards, Tim Stepan Mishura wrote: On 5/12/06, *Jimmy, Jing Lv* wrote: SNIP In this case,

Re: [classlib] Request for golden ticket to update String class (was: Re: [classlib] Exception throwing compatibility)

2006-05-13 Thread Tim Ellison
I agree with your analysis. +1 from me. Regards, Tim Stepan Mishura wrote: On 5/12/06, *Jimmy, Jing Lv* wrote: SNIP In this case, though replace StringIndexOutOfBoundsException with ArrayIndexOutOfBoundsException is surely better, it seems it is internal

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Mikhail Loenko
://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuilder.html#insert( int,%20char) -Original Message- From: Mikhail Loenko [mailto:[EMAIL PROTECTED] Sent: Thursday, May 11, 2006 9:48 PM To: harmony-dev@incubator.apache.org Subject: Re: [classlib] Exception throwing compatibility 2006/5/12

RE: [classlib] Exception throwing compatibility

2006-05-12 Thread Semukhina, Elena V
2006/5/12, Jimmy, Jing Lv [EMAIL PROTECTED]: Mikhail Fursov wrote: I agree that the easiest way for us is to throw RI or subclass. +1. Is it 'bad' practice to fix this bug (replace subclass with RI) on user request and do not think about this problem today? In this

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Jimmy, Jing Lv
Stepan Mishura wrote: On 5/12/06, Jimmy, Jing Lv wrote: Mikhail Fursov wrote: I agree that the easiest way for us is to throw RI or subclass. +1. Is it 'bad' practice to fix this bug (replace subclass with RI) on user request and do not think about this problem today? In this case,

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Mikhail Fursov
Note that this is not only beautiful but also performance oriented way - do not create extra rethrows if it's possible On 5/12/06, Semukhina, Elena V [EMAIL PROTECTED] wrote: To have a beautiful fix, why don't you just write System.arraycopy(data, start, value, 0, count); without trying

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Tim Ellison
Mikhail Loenko wrote: 2006/5/12, Jimmy, Jing Lv [EMAIL PROTECTED]: snip However according to http://incubator.apache.org/harmony/subcomponents/classlibrary/compat.html it has already draw a conclusion that: 1) throw according to spec 2) when we discover RI throw difference exception which

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Tim Ellison
Nathan Beyer wrote: snip What is the value in changing the 1 method that throws StringIndexOutOfBoundsException to ArrayIndexOutOfBoundsException? According to the compatibility guidelines, first and foremost we follow the specification. The documented exception (no pun intended) to this rule

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Chris Gray
More generally, from a performance point of view it is best not to write if (index 0 || index = array.length || etc. etc.) { throw new FooIndexOutOfBoundsException(); } if there is a method call or an array access which will throw the exception anyway. (Many null parameter checks can be

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Alexey Petrenko
2006/5/12, Nathan Beyer [EMAIL PROTECTED]: What is the value in changing the 1 method that throws StringIndexOutOfBoundsException to ArrayIndexOutOfBoundsException? The value is that possible user application depending on RI's behaviour will work with ArrayIndexOutOfBoundsException but will

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Ivan Volosyuk
I have different opinion there. This exception is quite rare in this function, isn't it? If so, we can optimize common pass by removing explicit checks. It could be performance beneficial. There other point here, internal exception can be lazy exception or even be optimized out. On DRLVM IMHO if

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Jimmy, Jing Lv
Chris Gray wrote: More generally, from a performance point of view it is best not to write if (index 0 || index = array.length || etc. etc.) { throw new FooIndexOutOfBoundsException(); } if there is a method call or an array access which will throw the exception anyway. (Many null

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread George Harley
] Exception throwing compatibility 2006/5/12, Jimmy, Jing Lv [EMAIL PROTECTED]: Mikhail Fursov wrote: I agree that the easiest way for us is to throw RI or subclass. +1. Is it 'bad' practice to fix this bug (replace subclass with RI) on user request and do

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Chris Gray
On Friday 12 May 2006 11:37, George Harley wrote: Nathan Beyer wrote: Note, the RI is NOT throwing ArrayIndexOutOfBoundsExceptions, it is just letting them happen via invalid array look ups, but in these cases, the specification is marked with an IndexOutOfBoundsException. Hi Nathan, If

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Mikhail Loenko
2006/5/12, Tim Ellison [EMAIL PROTECTED]: Mikhail Loenko wrote: 2006/5/12, Jimmy, Jing Lv [EMAIL PROTECTED]: snip However according to http://incubator.apache.org/harmony/subcomponents/classlibrary/compat.html it has already draw a conclusion that: 1) throw according to spec 2) when we

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Mikhail Loenko
2006/5/12, George Harley [EMAIL PROTECTED]: It sounds like there are as many interpretations of the guidelines as their are correspondents on this topic :-) My suggested change would be that we state that Harmony class library code should throw exceptions of the same runtime class as the RI.

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread George Harley
Chris Gray wrote: On Friday 12 May 2006 11:37, George Harley wrote: Nathan Beyer wrote: Note, the RI is NOT throwing ArrayIndexOutOfBoundsExceptions, it is just letting them happen via invalid array look ups, but in these cases, the specification is marked with an

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread George Harley
Mikhail Loenko wrote: 2006/5/12, George Harley [EMAIL PROTECTED]: It sounds like there are as many interpretations of the guidelines as their are correspondents on this topic :-) My suggested change would be that we state that Harmony class library code should throw exceptions of the same

Re: [classlib] Exception throwing compatibility

2006-05-12 Thread Mikhail Loenko
Hi George, 2006/5/12, George Harley [EMAIL PROTECTED]: Mikhail Loenko wrote: 2006/5/12, George Harley [EMAIL PROTECTED]: It sounds like there are as many interpretations of the guidelines as their are correspondents on this topic :-) My suggested change would be that we state that Harmony

Re: [classlib] Exception throwing compatibility

2006-05-11 Thread Chris Gray
Hi, * Dmitry (who raised the issue) believes that we should change the Harmony code to throw the type named in the Javadoc/specification (i.e. the supertype j.l.IndexOutOfBoundsException). Dmitry is wrong. * Nathan believes that the code already abides by the specification and that there

Re: [classlib] Exception throwing compatibility

2006-05-11 Thread Alexey Petrenko
I agree with George and Mikhail that we should throw the same exception with RI. Do not forget about developers who expects this behaviour. If their application works OK on RI and fails with StringIndexOutOfBoundsException on Harmony they will probably return to RI. Everybody is lazy and do not

Re: [classlib] Exception throwing compatibility

2006-05-11 Thread Richard Liang
George Harley wrote: Hi, I would like to start a little discussion around JIRA issue 436 [1] which deals with exception throwing compatibility between Harmony and the RI. I feel it is important to reach a concrete agreement on this as so far all of the participants in the issue seem to

Re: [classlib] Exception throwing compatibility

2006-05-11 Thread Geir Magnusson Jr
George Harley wrote: * Little old me thinks that there *is* a problem here but that the solution is to do as the RI does and throw exceptions with the very same runtime type as the RI. That's based on my interpretation of the exception-throwing compatibility guidelines [2], in particular

Re: [classlib] Exception throwing compatibility

2006-05-11 Thread Andrew Zhang
Hi, George I agree with your point. Harmony should throw the same type exception as RI unless we have sufficient reason such as RI conflict with spec, or RI's behaviour is illogical or Harmony can't produce the same exception as RI. On 5/11/06, George Harley [EMAIL PROTECTED] wrote: Hi, I

Re: [classlib] Exception throwing compatibility

2006-05-11 Thread Mikhail Loenko
What is the reason for prohibiting throwing a sub-class? Every existing try... catch construction will work Do we really want to convert all tests like try { do something fail(); } catch (SomeException e) { //expected } to something like try { do something fail(); } catch

Re: [classlib] Exception throwing compatibility

2006-05-11 Thread Mikhail Fursov
I agree that the easiest way for us is to throw RI or subclass. Is it 'bad' practice to fix this bug (replace subclass with RI) on user request and do not think about this problem today? On 5/11/06, Richard Liang [EMAIL PROTECTED] wrote: George Harley wrote: Hi, I would like to start a

Re: [classlib] Exception throwing compatibility

2006-05-11 Thread Jimmy, Jing Lv
Mikhail Fursov wrote: I agree that the easiest way for us is to throw RI or subclass. +1. Is it 'bad' practice to fix this bug (replace subclass with RI) on user request and do not think about this problem today? In this case, though replace StringIndexOutOfBoundsException with

Re: [classlib] Exception throwing compatibility

2006-05-11 Thread Stepan Mishura
On 5/12/06, Jimmy, Jing Lv wrote: Mikhail Fursov wrote: I agree that the easiest way for us is to throw RI or subclass. +1. Is it 'bad' practice to fix this bug (replace subclass with RI) on user request and do not think about this problem today? In this case, though replace

RE: [classlib] Exception throwing compatibility

2006-05-11 Thread Nathan Beyer
: Thursday, May 11, 2006 9:48 PM To: harmony-dev@incubator.apache.org Subject: Re: [classlib] Exception throwing compatibility 2006/5/12, Jimmy, Jing Lv [EMAIL PROTECTED]: Mikhail Fursov wrote: I agree that the easiest way for us is to throw RI or subclass. +1. Is it 'bad' practice

[classlib] Exception throwing compatibility

2006-05-10 Thread George Harley
Hi, I would like to start a little discussion around JIRA issue 436 [1] which deals with exception throwing compatibility between Harmony and the RI. I feel it is important to reach a concrete agreement on this as so far all of the participants in the issue seem to disagree about the