Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 73580 invoked from network); 11 Sep 2007 18:20:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Sep 2007 18:20:32 -0000 Received: (qmail 54673 invoked by uid 500); 11 Sep 2007 18:20:25 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 54461 invoked by uid 500); 11 Sep 2007 18:20:24 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 54452 invoked by uid 99); 11 Sep 2007 18:20:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 11:20:24 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of msatoor@gmail.com designates 209.85.132.249 as permitted sender) Received: from [209.85.132.249] (HELO an-out-0708.google.com) (209.85.132.249) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 18:20:23 +0000 Received: by an-out-0708.google.com with SMTP id c8so291751ana for ; Tue, 11 Sep 2007 11:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=Y8okW/zb/JncLnrmFbI+8HhF6BkxcRn1vm51vVocaeg=; b=G5PUexROdfikVNMYucOYRnzFiLdQEJPyxsJxDqXdSUXE7GVki1z+UZvD3RtHXB6e6eENhxwRMggXWdAv0f2QDhe5zDUkU4m5OboROavnkkJsIj7xuCZVNHFm4vqUt730jiMlanNBe5lm0oWGvr3wGuWYYyMl4PTQfsOJRaFfHy4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=SsRd1LCOXGeskpIzBl/RjE1hbi61NhRgFMj16ypOOMcEtigmD0zcqhQdeQMWpnldFaiZSyac4JpVuFTP/hoX9eF37dcOnk0v1KQOBY2YP5IDtf/KKuYrS+365/FUnSD62NiR58VmQNcBG6mO2GqAKVcQoSNei5OiqXFpPABHnas= Received: by 10.100.197.15 with SMTP id u15mr6918617anf.1189534802256; Tue, 11 Sep 2007 11:20:02 -0700 (PDT) Received: by 10.100.131.1 with HTTP; Tue, 11 Sep 2007 11:20:02 -0700 (PDT) Message-ID: Date: Tue, 11 Sep 2007 11:20:02 -0700 From: "Mamta Satoor" To: derby-dev@db.apache.org, mikem_app@sbcglobal.net Subject: Re: Question about next() and previous() on CollationElementIterator. In-Reply-To: <46E6CE66.4010904@sbcglobal.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_9481_20748799.1189534802245" References: <46E6CE66.4010904@sbcglobal.net> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_9481_20748799.1189534802245 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks for checking this, Mike. thanks, Mamta On 9/11/07, Mike Matrigali wrote: > > My reading of the documentation interface is the same as yours, so your > results look like a jvm bug. You may want to add some other simple > strings and maybe > other locales to see if a specific locale is broken or not. > > I hacked my own test to try to mimic the example code in the > documentation as much as possible and then tried a few variants. It > looks like a problem with the locale/test case you picked on sun jvms. > I tried the program on the ibm15 jvm and got the expected results. My > guess is that your eclipse environment is somehow picking up the ibm jvm? > > Here is my test program: > > import java.text.Collator; > import java.text.RuleBasedCollator; > import java.util.Locale; > import java.text.CollationElementIterator; > > public class xxx > { > public static void tryIt1() > throws Exception > { > String testString = "This is a test"; > RuleBasedCollator ruleBasedCollator = > (RuleBasedCollator)Collator.getInstance(); > CollationElementIterator collationElementIterator = > ruleBasedCollator.getCollationElementIterator(testString); > int primaryOrder = > CollationElementIterator.primaryOrder( > collationElementIterator.next()); > int primaryOrder2 = > CollationElementIterator.primaryOrder( > collationElementIterator.previous()); > System.out.println( > "next = " + primaryOrder + " \nprevious = " + primaryOrder2); > } > public static void tryIt2() > throws Exception > { > String testString = "\uFA2D"; > RuleBasedCollator ruleBasedCollator = > (RuleBasedCollator)Collator.getInstance(); > CollationElementIterator collationElementIterator = > ruleBasedCollator.getCollationElementIterator(testString); > int primaryOrder = > CollationElementIterator.primaryOrder( > collationElementIterator.next()); > int primaryOrder2 = > CollationElementIterator.primaryOrder( > collationElementIterator.previous()); > System.out.println( > "next = " + primaryOrder + " \nprevious = " + primaryOrder2); > } > public static void tryIt3() > throws Exception > { > String testString = "\uFA2D"; > RuleBasedCollator ruleBasedCollator = > (RuleBasedCollator)Collator.getInstance(new > Locale("no","NO")); > CollationElementIterator collationElementIterator = > ruleBasedCollator.getCollationElementIterator(testString); > int primaryOrder = > CollationElementIterator.primaryOrder( > collationElementIterator.next()); > int primaryOrder2 = > CollationElementIterator.primaryOrder( > collationElementIterator.previous()); > System.out.println( > "next = " + primaryOrder + " \nprevious = " + primaryOrder2); > } > public static void tryIt4() > throws Exception > { > String testString = "\uFA2D"; > RuleBasedCollator ruleBasedCollator = > (RuleBasedCollator)Collator.getInstance(new > Locale("no","NO")); > CollationElementIterator collationElementIterator = > ruleBasedCollator.getCollationElementIterator(testString); > int next_order = collationElementIterator.next(); > int previous_order = collationElementIterator.previous(); > System.out.println( > "next = " + next_order + " \nprevious = " + previous_order); > } > > public static void main(String[] args) > throws Exception > { > tryIt1(); > tryIt2(); > tryIt3(); > tryIt4(); > } > } > > And my JVM results, all results are on windows XP: > > BUG on sun jdk16: > m1_jdk16:5>java -version > java version "1.6.0_01" > Java(TM) SE Runtime Environment (build 1.6.0_01-b06) > Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode) > m1_jdk16:6>java xxx > next = 102 > previous = 102 > next = 32767 > previous = 64045 > next = 32767 > previous = 64045 > next = 2147418112 > previous = -97714176 > > BUG on sun jdk15: > m1_jdk15:2>java -version > java version "1.5.0_02" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09) > Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode) > m1_jdk15:3>export CLASSPATH=".;$CLASSPATH" > m1_jdk15:4>java -version > java version "1.5.0_02" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09) > Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode) > m1_jdk15:5>java xxx > next = 102 > previous = 102 > next = 32767 > previous = 64045 > next = 32767 > previous = 64045 > next = 2147418112 > previous = -97714176 > > LOOKS CORRECT ON IBM15 > m1_ibm15:37>java -version > java version "1.5.0" > Java(TM) 2 Runtime Environment, Standard Edition (build > pwi32dev-20061002a (SR3) > ) > IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 > j9vmwi3223-2006100 > 1 (JIT enabled) > J9VM - 20060915_08260_lHdSMR > JIT - 20060908_1811_r8 > GC - 20060906_AA) > JCL - 20061002 > m1_ibm15:38>java xxx > next = 102 > previous = 102 > next = 32767 > previous = 32767 > next = 32767 > previous = 32767 > next = 2147418112 > previous = 2147418112 > > Mamta Satoor wrote: > > Hi, > > > > I have a very simple program(included at the bottom of the mail) which > > uses the CollationElementIterator to do some very basic next/previous > > method calls through the iterator. When I run the program, it is not > > behaving as per the JDBC API documentation at > > > http://java.sun.com/j2se/1.5.0/docs/api/java/text/CollationElementIterator.html#next() > > The JDBC API for next and previous very specifically say that "call > > next() and then call previous(), or call previous() and then call > > next()), you'll get back the same element twice." But when I execute the > > following program with Sun's jdk 1.5 on command line, I get following > output > > next is 2147418112 > > previous is -97714176 > > > > I had expected the output to be > > next is 2147418112 > > previous is 2147418112 > > > > Am I doing something wrong here or not interpreting the documentation > > correctly? Any help will be greatly appreciated. As a side note, when I > > run the same program through the Eclipse debugger, I get the expected > > behavior which is that next and previous both return the same value. > > > > thanks, > > Mamta > > > > import java.text.Collator; > > import java.text.RuleBasedCollator; > > import java.util.Locale; > > import java.text.CollationElementIterator; > > > > public class simpleTest { > > public static String aa = "\uFA2D"; > > > > public static void main(String[] args) throws Exception { > > RuleBasedCollator myCollator = > > (RuleBasedCollator)Collator.getInstance(new Locale("no","NO")); > > CollationElementIterator anIterator = > > myCollator.getCollationElementIterator(aa); > > System.out.println("next is " + anIterator.next()); > > System.out.println("previous is " + anIterator.previous()); > > } > > } > > > > > ------=_Part_9481_20748799.1189534802245 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Thanks for checking this, Mike.
 
thanks,
Mamta

 
On 9/11/07, Mike Matrigali <mikem_app@sbcglobal.net> wrote:
My reading of the documentation interface is the same as yours, so your
results look like a jvm bug.  You may want to add some other simple
strings and maybe
other locales to see if a specific locale is broken or not.

I hacked my own test to try to mimic the example code in the
documentation as much as possible and then tried a few variants.  It
looks like a problem with the locale/test case you picked on sun jvms.
I tried the program on the ibm15 jvm and got the expected results.  My
guess is that your eclipse environment is somehow picking up the ibm jvm?

Here is my test program:

import java.text.Collator;
import java.text.RuleBasedCollator;
import java.util.Locale;
import java.text.CollationElementIterator;

public class xxx
{
    public static void tryIt1()
    throws Exception
    {
        String testString = "This is a test";
        RuleBasedCollator ruleBasedCollator =
            (RuleBasedCollator)Collator.getInstance();
        CollationElementIterator collationElementIterator =
            ruleBasedCollator.getCollationElementIterator(testString);
        int primaryOrder =
            CollationElementIterator.primaryOrder(
                    collationElementIterator.next());
        int primaryOrder2 =
            CollationElementIterator.primaryOrder(
                    collationElementIterator.previous());
        System.out.println(
            "next = " + primaryOrder + " \nprevious = " + primaryOrder2);
    }
    public static void tryIt2()
    throws Exception
    {
        String testString = "\uFA2D";
        RuleBasedCollator ruleBasedCollator =
            (RuleBasedCollator)Collator.getInstance();
        CollationElementIterator collationElementIterator =
            ruleBasedCollator.getCollationElementIterator(testString);
        int primaryOrder =
            CollationElementIterator.primaryOrder(
                    collationElementIterator.next());
        int primaryOrder2 =
            CollationElementIterator.primaryOrder(
                    collationElementIterator.previous());
        System.out.println (
            "next = " + primaryOrder + " \nprevious = " + primaryOrder2);
    }
    public static void tryIt3()
    throws Exception
    {
        String testString = "\uFA2D";
        RuleBasedCollator ruleBasedCollator =
            (RuleBasedCollator)Collator.getInstance(new Locale("no","NO"));
        CollationElementIterator collationElementIterator =
             ruleBasedCollator.getCollationElementIterator(testString);
        int primaryOrder =
            CollationElementIterator.primaryOrder(
                    collationElementIterator.next());
        int primaryOrder2 =
            CollationElementIterator.primaryOrder(
                    collationElementIterator.previous());
        System.out.println(
            "next = " + primaryOrder + " \nprevious = " + primaryOrder2);
    }
    public static void tryIt4()
    throws Exception
    {
        String testString = "\uFA2D";
        RuleBasedCollator ruleBasedCollator =
            (RuleBasedCollator)Collator.getInstance(new Locale("no","NO"));
        CollationElementIterator collationElementIterator =
            ruleBasedCollator.getCollationElementIterator(testString);
        int next_order = collationElementIterator.next();
        int previous_order =   collationElementIterator.previous();
        System.out.println(
            "next = " + next_order + " \nprevious = " + previous_order);
    }

    public static void main(String[] args)
    throws Exception
    {
        tryIt1();
        tryIt2();
        tryIt3();
        tryIt4();
    }
}

And my JVM results, all results are on windows XP:

BUG on sun jdk16:
m1_jdk16:5>java -version
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode)
m1_jdk16:6>java xxx
next = 102
previous = 102
next = 32767
previous = 64045
next = 32767
previous = 64045
next = 2147418112
previous = -97714176

BUG on sun jdk15:
m1_jdk15:2>java -version
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode)
m1_jdk15:3>export CLASSPATH=".;$CLASSPATH"
m1_jdk15:4>java -version
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode)
m1_jdk15:5>java xxx
next = 102
previous = 102
next = 32767
previous = 64045
next = 32767
previous = 64045
next = 2147418112
previous = -97714176

LOOKS CORRECT ON IBM15
m1_ibm15:37>java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build
pwi32dev-20061002a (SR3)
)
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32
j9vmwi3223-2006100
1 (JIT enabled)
J9VM - 20060915_08260_lHdSMR
JIT  - 20060908_1811_r8
GC   - 20060906_AA)
JCL  - 20061002
m1_ibm15:38>java xxx
next = 102
previous = 102
next = 32767
previous = 32767
next = 32767
previous = 32767
next = 2147418112
previous = 2147418112

Mamta Satoor wrote:
> Hi,
>
> I have a very simple program(included at the bottom of the mail) which
> uses the CollationElementIterator to do some very basic next/previous
> method calls through the iterator. When I run the program, it is not
> behaving as per the JDBC API documentation at
> http://java.sun.com/j2se/1.5.0/docs/api/java/text/CollationElementIterator.html#next()
> The JDBC API for next and previous very specifically say that "call
> next() and then call previous(), or call previous() and then call
> next()), you'll get back the same element twice." But when I execute the
> following program with Sun's jdk 1.5 on command line, I get following output
> next is 2147418112
> previous is -97714176
>
> I had expected the output to be
> next is 2147418112
> previous is 2147418112
>
> Am I doing something wrong here or not interpreting the documentation
> correctly? Any help will be greatly appreciated. As a side note, when I
> run the same program through the Eclipse debugger, I get the expected
> behavior which is that next and previous both return the same value.
>
> thanks,
> Mamta
>
> import java.text.Collator ;
> import java.text.RuleBasedCollator;
> import java.util.Locale;
> import java.text.CollationElementIterator;
>
> public class simpleTest {
>  public static String aa = "\uFA2D";
>
>  public static void main(String[] args) throws Exception {
>   RuleBasedCollator myCollator =
> (RuleBasedCollator)Collator.getInstance(new Locale("no","NO"));
>   CollationElementIterator anIterator =
> myCollator.getCollationElementIterator(aa);
>   System.out.println("next is " + anIterator.next());
>   System.out.println("previous is " + anIterator.previous());
>  }
> }
>
>

------=_Part_9481_20748799.1189534802245--