harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paulex Yang <paulex.y...@gmail.com>
Subject [classlib]bug-to-bug incompatibility issue: java.util.Formatter's flag handling
Date Mon, 15 May 2006 07:05:41 GMT
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 

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

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

View raw message