Index: api/java/common/java/awt/FontTest.java =================================================================== --- api/java/common/java/awt/FontTest.java (revision 448875) +++ api/java/common/java/awt/FontTest.java (working copy) @@ -16,8 +16,10 @@ package java.awt; +import java.awt.font.FontRenderContext; import java.awt.font.TextAttribute; import java.text.AttributedString; +import java.text.CharacterIterator; import junit.framework.TestCase; @@ -64,5 +66,40 @@ } } - + + /* + * Compatibility test. We check that Harmony throws same + * exceptions as RI does. + */ + public void test_Font_getStringBounds_WithNullTextSource() { + // regression test for Harmony-1591 + Font font = new Font("dialog", Font.PLAIN, 12); + FontRenderContext cnt = new FontRenderContext(null, false, true); + try{ + font.getStringBounds((char[]) null, -16, 1, cnt); + }catch (IndexOutOfBoundsException e) { + // expected + } + + try{ + font.getStringBounds((String) null, -16, 1, cnt); + }catch (NullPointerException e) { + // expected + } + + try{ + font.getStringBounds((CharacterIterator) null, -16, 1, cnt); + }catch (NullPointerException e) { + // expected + } + + + try{ + font.getStringBounds((String) null, cnt); + }catch (NullPointerException e) { + // expected + } + + } + }