harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilya Okomin (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-1595) [classlib][awt]Compatibility: java.awt.Font.getStringBounds() methods for null FontRenderContext returns bounds on Harmony and throws NPE on RI
Date Tue, 26 Sep 2006 16:13:50 GMT
[classlib][awt]Compatibility: java.awt.Font.getStringBounds() methods for null FontRenderContext
returns bounds on Harmony and throws NPE on RI
-----------------------------------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-1595
                 URL: http://issues.apache.org/jira/browse/HARMONY-1595
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Ilya Okomin
            Priority: Minor


java.awt.Font.getStringBounds() methods for null FontRenderContext returns bounds on Harmony
and throws NPE on RI.
Spec says nothing about any exceptions for getStringBounds() methods.
You can check this running next test case:
-------------------test.java---------------------
import junit.framework.TestCase;

import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.text.StringCharacterIterator;

public class test extends TestCase {

    public static void main(String[] args) {
        junit.textui.TestRunner.run(test.class);
    }

    public void testRun() {
        Font font = Font.decode("Arial");
        try {
            font.getStringBounds(new char[] { 'a' }, 0, 1,
                    (FontRenderContext) null);
            System.out.println("Fail: NullPointerException expected!");
        }catch (Exception e) {
            if (e instanceof NullPointerException) {
                System.out.println("Success: " + e);
            } else {
                System.out.println("Fail: " + e);
            }
        }

        try {
            font.getStringBounds(new StringCharacterIterator("a"), 0, 1,
                    (FontRenderContext) null);
            System.out.println("Fail: NullPointerException expected!");
        }catch (Exception e) {
            if (e instanceof NullPointerException) {
                System.out.println("Success: " + e);
            } else {
                System.out.println("Fail: " + e);
            }
        }
        
        String str = "str";
        try {
            font.getStringBounds(str, 0, 1, (FontRenderContext) null);
            System.out.println("Fail: NullPointerException expected!");
        }catch (Exception e) {
            if (e instanceof NullPointerException) {
                System.out.println("Success: " + e);
            } else {
                System.out.println("Fail: " + e);
            }
        }

        try {
            font.getStringBounds(str, (FontRenderContext) null);
            System.out.println("Fail: NullPointerException expected!");
        }catch (Exception e) {
            if (e instanceof NullPointerException) {
                System.out.println("Success: " + e);
            } else {
                System.out.println("Fail: " + e);
            }
        }

    }

}
---------------------------------------------

====== Output RI ====== 

.Success: java.lang.NullPointerException
Success: java.lang.NullPointerException
Success: java.lang.NullPointerException
Success: java.lang.NullPointerException

Time: 2.183

OK (1 test)

====== Output Harmony =======

.Fail: NullPointerException expected!
Fail: NullPointerException expected!
Fail: NullPointerException expected!
Fail: NullPointerException expected!

Time: 0.36

OK (1 test)

Don't pay attention to the successful test pass - compare only output.


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

        

Mime
View raw message