[ http://issues.apache.org/jira/browse/HARMONY-59?page=all ] Tim Ellison resolved HARMONY-59: --------------------------------
Resolution: Fixed That patch is good -- thanks Nathan. Fixed in TEXT java.text.ChoiceFormat at repo revision 375969. Tatyana : please check that this fully resolves your problem. > java.text.MessageFormat.toPattern() causes IndexOutOfBoundsException in > StringBuffer.setLength method > ------------------------------------------------------------------------------------------------------ > > Key: HARMONY-59 > URL: http://issues.apache.org/jira/browse/HARMONY-59 > Project: Harmony > Type: Bug > Components: Classlib > Reporter: tatyana doubtsova > Assignee: Tim Ellison > Attachments: ChoiceFormatTest.java, ChoiceFormat_patches.txt > > Problem details: > According to j2se 1.4.2, method toPattern() should return a pattern > representing the current state of the message format. However, Harmony throws > IndexOutOfBoundsException for "CHOICE {1,choice}" message format. > Code for reproducing Test.java: > import java.text.*; > public class Test { > public static void main(String[] args) { > MessageFormat mf = new MessageFormat("CHOICE > {1,choice}"); > String ptrn = mf.toPattern(); > System.out.println("ptrn = " + ptrn); > } > } > Steps to Reproduce: > 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in > README.txt. > 2. Compile Test.java using BEA 1.4 javac > > javac -d . Test.java > 3. Run java using compatible VM (J9) > > java -showversion Test > Output: > java version 1.4.2 (subset) > (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as > applicable. > Exception in thread "main" java.lang.IndexOutOfBoundsException > at java.lang.StringBuffer.setLength(StringBuffer.java:810) > at java.text.ChoiceFormat.toPattern(ChoiceFormat.java:386) > at java.text.MessageFormat.toPattern(MessageFormat.java:802) > at Test.main(Test.java:5) > Output on BEA 1.4.2 to compare with: > ptrn = CHOICE {1,choice,} > Suggested junit test case: > package org.apache.harmony.tests.java.text; > import java.text.MessageFormat; > import java.util.Locale; > import junit.framework.TestCase; > public class MessageFormatTest extends TestCase { > public static void main(String[] args) { > junit.textui.TestRunner.run(MessageFormatTest.class); > } > public void test_toPattern() { > try { > MessageFormat mf = new MessageFormat("CHOICE {1,choice}"); > String ptrn = mf.toPattern(); > } catch (Exception e) { > fail("Assert 0: Unexpected exception " + e); > } > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira