Home » Java » Core Java » Java – Missing font – Crashing App!

About Ram Lakshmanan

Ram Lakshmanan
Ram Lakshmanan developed world's finest DevOps tools: GCeasy.io, fastThread.io, HeapHero.io. Every single day, millions & millions of people in North America—bank, travel, and commerce—use the applications that Ram Lakshmanan has architected. Ram is an acclaimed speaker in major conferences on scalability, availability, and performance topics. Recently, he has founded a startup, which specializes in troubleshooting performance problems.

Java – Missing font – Crashing App!

Eclipse MATHeaphero are all popular java tools to analyze large size heap dumps. Recently we ran in to an interesting problem when trying to analyze a heap dump file in Eclipse MAT. Tool was crashing because of missing font 😊. We thought we will share with you what we found out.

ArrayIndexOutOfBoundsException  in CompositeStrike.getStrikeForSlot()

Here is our environment:

  • Eclipse MAT 1.9
  • Java 8
  • Linux 3.10.0-862.34.2.el7.x86_64

When we uploaded our heap dump file to Eclipse MAT, it failed with following error:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
java.lang.ArrayIndexOutOfBoundsException: 0
               at sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:75)
               at sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93
               at sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:359)
               at sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:350)
               at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:302)
               at sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:863)
               at org.eclipse.birt.chart.device.swing.SwingTextMetrics.reuse(SwingTextMetrics.java:123)
               at org.eclipse.birt.chart.device.TextAdapter.reuse(TextAdapter.java:36)
               at org.eclipse.birt.chart.device.swing.SwingTextMetrics.<init>(SwingTextMetrics.java:86)
               at org.eclipse.birt.chart.device.swing.SwingDisplayServer.getTextMetrics(SwingDisplayServer.java:194)
               at org.eclipse.birt.chart.device.DisplayAdapter.getTextMetrics(DisplayAdapter.java:138)
               at org.eclipse.birt.chart.computation.BIRTChartComputation.getTextMetrics(BIRTChartComputation.java:36)
               at org.eclipse.birt.chart.computation.LegendBuilder$LegendData.<init>(LegendBuilder.java:108)
               at org.eclipse.birt.chart.computation.LegendBuilder.compute(LegendBuilder.java:493)
               at org.eclipse.birt.chart.model.layout.impl.LegendImpl.getPreferredSize(LegendImpl.java:2059)
               at org.eclipse.birt.chart.internal.layout.LayoutManager$ChartLayout.<init>(LayoutManager.java:126)
               at org.eclipse.birt.chart.internal.layout.LayoutManager.doLayout_tmp(LayoutManager.java:1145)
 :
 :            
 :

 Quick search in Google god revealed this interesting StackOverflow thread. Here is synopsis of this thread. Java searches monospaced, SansSerif and serif fonts using linux’s fontconfig feature. Linux fontconfig is designed to locate fonts within the system and select them according to requirements specified by applications. If any of the above font are missing, then it would result in above exception.

 If you also encounter this type of problem, there are 3 potential solutions to address this problem:

 1. Install missing font

 2. Upgrade JDK

 3. Edit OS Font config

Let’s discuss the solutions in detail.

1.     Install missing font

 You can try installing the missing font by issuing below command:

1
yum install dejavu-serif-fonts

2. Upgrade JDK

 This is a known JDK bug, tracked in OpenJDK, Oracle and IBM JDK bug databases:

 This bug has been fixed since following releases:

 Open JDK 8u192

 Oracle JDK 8u192

 IBM JDK 8 SR5 FP37 (8.0.5.37)

 You can upgrade to latest JDK version to resolve the problem.

3.  Edit OS Font config

Create a file name /etc/fonts/local.conf. In this file force back Utopia as the default font, used by java.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <alias>
    <family>serif</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
  <alias>
    <family>dialog</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
  <alias>
    <family>dialoginput</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
</fontconfig>

Published on Java Code Geeks with permission by Ram Lakshmanan, partner at our JCG program. See the original article here: Java – Missing font – Crashing App!

Opinions expressed by Java Code Geeks contributors are their own.

(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of