You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Paulex Yang <pa...@gmail.com> on 2006/05/15 09:05:41 UTC

[classlib]bug-to-bug incompatibility issue: java.util.Formatter's flag handling

RI's java.util.Formatter has inconsistent behavior on incompatible flags 
handling: different kind of conversions has similar spec on this issue, 
which only cover one flag "#" - "If the '#' flag is given, then a 
FormatFlagsConversionMismatchException will be thrown", and most kind of 
conversions in RI ignore other incompatible flags, but there is one kind 
of conversion named as "general conversion" throws exception on all 
incompatible flags.

For example, the sign flag of "+" is incompatible with both character 
conversion and general conversion, and character conversion ignore it 
while general conversion throws exception, the test case below shows the 
difference:

public class FormatterTest extends TestCase {
    public void testFormat() {
        Formatter f = new Formatter(Locale.US);
        //Character conversion, incompatible flag "+" is ignored
        f.format("%+c", 'W');
        assertEquals("W", f.toString());

        f = new Formatter(Locale.US);
        try {
            //General conversion, incompatible flag "+" is reported
            f.format("%+h", "hello");
            fail("FormatFlagsConversionMismatchException is thrown on RI");
        } catch (FormatFlagsConversionMismatchException e) {
            // expected
        }
    }
}

Should we consider RI's behavior is not logical? or just make Harmony 
comply with RI?

-- 
Paulex Yang
China Software Development Lab
IBM



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