Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 56722 invoked from network); 2 Nov 2006 12:50:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Nov 2006 12:50:14 -0000 Received: (qmail 83358 invoked by uid 500); 2 Nov 2006 12:50:22 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 83177 invoked by uid 500); 2 Nov 2006 12:50:22 -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 83167 invoked by uid 99); 2 Nov 2006 12:50:22 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Nov 2006 04:50:22 -0800 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 (herse.apache.org: domain of alexey.a.petrenko@gmail.com designates 66.249.92.169 as permitted sender) Received: from [66.249.92.169] (HELO ug-out-1314.google.com) (66.249.92.169) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Nov 2006 04:50:08 -0800 Received: by ug-out-1314.google.com with SMTP id y2so133290uge for ; Thu, 02 Nov 2006 04:49:47 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=fkoK4aLUOFm9dUNKp9Xqrx1xyHTgf1EFo4ezI/srpNiGihin2Da2SXQwfP6DPsiXGTGZEEDd8wVb9EBxuE4FZM8fOovEanPrUrm+Bg7KyPznW8Os3dgZHDC3Fkkl2UPJ8g6a/rXcJBvKE30jUqtXfOvl8RbejxgjkTnNYNubzoo= Received: by 10.78.118.19 with SMTP id q19mr578187huc.1162471786865; Thu, 02 Nov 2006 04:49:46 -0800 (PST) Received: by 10.78.107.10 with HTTP; Thu, 2 Nov 2006 04:49:46 -0800 (PST) Message-ID: Date: Thu, 2 Nov 2006 15:49:46 +0300 From: "Alexey Petrenko" To: harmony-dev@incubator.apache.org Subject: Re: [classlib][swing] compatibility: j.s.text.GapContent.replace() behaviour In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8E389A5F2FEABA4CB1DEC35A25CB39CE69567D@mssmsx411> <26c14c2a0611020427o5bd1ac8dhac99578210d439fb@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org HARMONY-1975is already applied and closed ;) 2006/11/2, Alexey Petrenko : > I'll take care of 1975. > > SY, Alexey > > 2006/11/2, Oleg Khaschansky : > > +1. Silently doing nothing if invalid parameters are passed seems to > > me a right behavior in this case. > > > > Will someone apply changes to GapContent from the harmony-1975.patch > > or we need to make a separate patch for this? > > > > On 11/2/06, Alexey Petrenko wrote: > > > 2006/11/2, Ivanov, Alexey A : > > > > Hi all, > > > > > > > > I've started fixing HARMONY-1809. To remove throws clause from the > > > > declaration of replace method, as it was proposed by Oleg in > > > > HARMONY-1975, I placed removeItems() and insertItems() calls into > > > > try-catch block. This would work OK for any valid arguments. > > > > > > > > I was going to handle invalid arguments by making adjustments so that > > > > the following removeItems() and insertItems() will not throw the > > > > exception. After I wrote several tests, I faced strange behaviour of RI > > > > with regards to invalid arguments to replace. > > > > > > > > (The Javadoc say nothing about which valid ranges for replace() > > > > parameters as well as any exceptions.) > > > > > > > > RI accepts invalid arguments but the result differs from what I'd > > > > expect. > > > > For example, if the content has "text" in it, I'd expect that > > > > content.replace(-2, 4, null, 0) would give "xt" as the result. I mean > > > > the invalid start position is adjusted to 0, and the length of remove is > > > > adjusted to be 2 accordingly. But this is not the case. As the result of > > > > this call, all characters are removed leaving "" in the content. > > > > > > > > Moreover the content object becomes unusable after that: > > > > content.insertString(0, "1") throws ArrayIndexOutOfBoundsException. > > > > > > > > Similarly if number of characters to be removed is greater than the > > > > length of the content (content.replace(2, 4, null, 0) with "text" in > > > > it), the object will throw ArrayIndexOutOfBoundsException when doing > > > > insertString. > > > > > > > > > > > > Considering the fact that GapContent is pretty low-level class in text > > > > representation model and that it is protected, I think that Harmony > > > > implementation can silently ignore BadLocationException possible thrown > > > > from insertItems() and removeItems(). Taking into account erroneous > > > > behaviour of RI's replace, we can do that until an application is > > > > broken. > > > +1 for this solution. > > > > > > SY, Alexey > > > > > > > As another option, we can throw an Error from catch block to make > > > > application which depends on implementation of replace() fast-fail. > > > > > > > > > > > > Any objections, comments, opinions? > > > > > > > > Thanks, > > > > Alexey. > > > > > > > > > > > > P.S. The related JIRA issues: > > > > https://issues.apache.org/jira/browse/HARMONY-1809 > > > > https://issues.apache.org/jira/browse/HARMONY-1975 > > > > > > > > GapContent Javadoc: > > > > http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/GapContent.html > > > > Description of GapContent.replace: > > > > http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/GapContent.html > > > > #replace(int,%20int,%20java.lang.Object,%20int) > > > > > > > > > > > > -- > > > > Alexey A. Ivanov > > > > Intel Middleware Product Division > > > > > > > > > >