From 7972a570d4a1fc58733a8ec19ba550012836794e Mon Sep 17 00:00:00 2001 From: prr Date: Wed, 22 Dec 2010 13:32:58 -0800 Subject: [PATCH] 7007299: FileFontStrike appears not to be threadsafe? Reviewed-by: igor, jgodinez --- src/share/classes/sun/font/FileFontStrike.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/share/classes/sun/font/FileFontStrike.java b/src/share/classes/sun/font/FileFontStrike.java index ce4d87c2a..ca72867f8 100644 --- a/src/share/classes/sun/font/FileFontStrike.java +++ b/src/share/classes/sun/font/FileFontStrike.java @@ -58,7 +58,7 @@ public class FileFontStrike extends PhysicalStrike { private static final int SEGINTARRAY = 3; private static final int SEGLONGARRAY = 4; - private int glyphCacheFormat = UNINITIALISED; + private volatile int glyphCacheFormat = UNINITIALISED; /* segmented arrays are blocks of 256 */ private static final int SEGSHIFT = 8; @@ -522,32 +522,33 @@ public class FileFontStrike extends PhysicalStrike { } /* Called only from synchronized code or constructor */ - private void initGlyphCache() { + private synchronized void initGlyphCache() { int numGlyphs = mapper.getNumGlyphs(); - + int tmpFormat = UNINITIALISED; if (segmentedCache) { int numSegments = (numGlyphs + SEGSIZE-1)/SEGSIZE; if (longAddresses) { - glyphCacheFormat = SEGLONGARRAY; + tmpFormat = SEGLONGARRAY; segLongGlyphImages = new long[numSegments][]; this.disposer.segLongGlyphImages = segLongGlyphImages; } else { - glyphCacheFormat = SEGINTARRAY; + tmpFormat = SEGINTARRAY; segIntGlyphImages = new int[numSegments][]; this.disposer.segIntGlyphImages = segIntGlyphImages; } } else { if (longAddresses) { - glyphCacheFormat = LONGARRAY; + tmpFormat = LONGARRAY; longGlyphImages = new long[numGlyphs]; this.disposer.longGlyphImages = longGlyphImages; } else { - glyphCacheFormat = INTARRAY; + tmpFormat = INTARRAY; intGlyphImages = new int[numGlyphs]; this.disposer.intGlyphImages = intGlyphImages; } } + glyphCacheFormat = tmpFormat; } float getGlyphAdvance(int glyphCode) { -- GitLab