7145771: [macosx] CreateFont/Register.java test fails because of cached results of getAllFonts()
Reviewed-by: igor, flar
--- 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;
}
}