# HG changeset patch # User prr # Date 1340728705 25200 # Node ID 9a70fa2cc59cdd03308a8ab55ed3d3f602623c51 # Parent 7ad469d89bede91243fa4c0f3a55e03ab57e77ba 7145771: [macosx] CreateFont/Register.java test fails because of cached results of getAllFonts() Reviewed-by: igor, flar diff -r 7ad469d89bed -r 9a70fa2cc59c jdk/src/macosx/classes/sun/awt/CGraphicsEnvironment.java --- a/jdk/src/macosx/classes/sun/awt/CGraphicsEnvironment.java Tue Jun 19 09:07:31 2012 -0700 +++ b/jdk/src/macosx/classes/sun/awt/CGraphicsEnvironment.java Tue Jun 26 09:38:25 2012 -0700 @@ -200,29 +200,25 @@ return true; } - private Font[] allFontsWithLogical; static String[] sLogicalFonts = { "Serif", "SansSerif", "Monospaced", "Dialog", "DialogInput" }; @Override public Font[] getAllFonts() { - if (allFontsWithLogical == null) - { - Font[] newFonts; - Font[] superFonts = super.getAllFonts(); - int numLogical = sLogicalFonts.length; - int numOtherFonts = superFonts.length; + Font[] newFonts; + Font[] superFonts = super.getAllFonts(); + + int numLogical = sLogicalFonts.length; + int numOtherFonts = superFonts.length; - newFonts = new Font[numOtherFonts + numLogical]; - System.arraycopy(superFonts,0,newFonts,numLogical,numOtherFonts); + newFonts = new Font[numOtherFonts + numLogical]; + System.arraycopy(superFonts,0,newFonts,numLogical,numOtherFonts); - for (int i = 0; i < numLogical; i++) - { - newFonts[i] = new Font(sLogicalFonts[i], Font.PLAIN, 1); - } - allFontsWithLogical = newFonts; + for (int i = 0; i < numLogical; i++) + { + newFonts[i] = new Font(sLogicalFonts[i], Font.PLAIN, 1); } - return java.util.Arrays.copyOf(allFontsWithLogical, allFontsWithLogical.length); + return newFonts; } }