-
Enhancement
-
Resolution: Fixed
-
P3
-
1.2.0
-
kestrel
-
generic
-
generic
Name: clC74495 Date: 07/26/99
=20
This problem can be found in the refernce version jdk1.2 / jdk1.2.2
and the solaris version 1.2.1_03:
The awt code that looks for type1 and truetype fonts
(.pfa/.pfb/.ttf/.ttc) installed on a solaris system
and checks if these fonts can be added to the X11 server's
fontpath performs too many open/lseek/close system calls
due to a logic error in src/solaris/native/sun/awt/font/fontpath.c,
function AddFontsToX11FontPath. Especially on the second or
later run of a jdk1.2 java program using the awt: in that
case, the X server's font path already contains all=20
necessary font directories from the first run!
The problem is, that AddFontsToX11FontPath checks the
readabilty of a "fonts.dir" file in the *inner* loop. This
test should be moved to the outer loop. The inner loop
checks, if the type1/truetype's font directory is already
contained in the X server's font path. Only if a type1/truetype's
directory is not found in the server's fontpath it makes sense to
check the existance of a fonts.dir file in that directory.
TEST CASE:
public class font {
public static void main(String[] args) {
new java.awt.Font("dialog", java.awt.Font.BOLD, 10);
System.exit(0);
}
}
Run this java program with truss and watch the part of the
trace when the awt starts looking for fonts.dir files:
% truss /usr/java1.2/bin/java font | & sed -n '/fonts.dir/,$p' | more
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
close(8) =3D 0
open("/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/fonts.dir", O_RDONLY=
) =3D 8
llseek(8, 0, SEEK_CUR) =3D 0
....
the open/llseek/close sequence of system calls repeats for
several pages (more than 50 pages in a dtterm window with
34 lines)
The same system call trace with my suggested fix installed has
eliminated all these superfluous open/llseek/close calls:
% truss /home/leo/src/jdk1.2-src/build/solaris/bin/java font | & sed -n '/f=
onts.dir/,$p' | more
open("/usr/openwin/lib/locale/ar/X11/fonts/Type1/fonts.dir", O_RDONLY) Err#=
2 ENO
ENT
brk(0x00132688) =3D 0
brk(0x00136688) =3D 0
brk(0x00136688) =3D 0
brk(0x00138688) =3D 0
...
(Review ID: 88174)=20
======================================================================