Name: dsR10051 Date: 08/06/2003
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b13"
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : N/A
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
/**
...
* @throws FontFormatException if the <code>fontStream</code> data does
* not contain the required font tables for the specified format.
* @throws IOException if the <code>fontStream</code>
* cannot be completely read.
* @since 1.3
*/
public static Font createFont(int fontFormat, InputStream fontStream)
throws java.awt.FontFormatException, java.io.IOException {
...
---------- end-of-excerpt ---------------
Problem description
===================
Method of class java.awt.Font
public static Font createFont(int fontFormat, InputStream fontStream)
throws java.awt.FontFormatException, java.io.IOException {
does not throw IOException if the fontStream cannot be completely read.
In this case method throws FontFormatException.
It seems IOException is catched by implementation and declaration of
IOException in throws block is unnecessary.
Minimized test:
===============
------- FontTest03.java -------
import java.awt.*;
import java.io.*;
public class FontTest03 {
public static void main(String[] args) {
InputStream fontStream = new InputStream() {
public int read() throws IOException {
throw new IOException("Test Exception");
}
};
Font font = null;
try {
font = Font.createFont(Font.TRUETYPE_FONT, fontStream);
} catch (FontFormatException ffe) {
System.out.println("Unexpected exception " + ffe);
System.exit(1);
} catch (IOException ioe) {
System.out.println("OKAY");
System.exit(0);
}
System.out.println("IOException expected");
}
}
------- end-of-FontTest03.java -------
Minimized test output:
======================
% java -version
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b13)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b13, mixed mode)
% java FontTest03
Unexpected exception java.awt.FontFormatException: Couldn't access font
stream
======================================================================