7145771: [macosx] CreateFont/Register.java test fails because of cached results of getAllFonts()
authorprr
Tue, 26 Jun 2012 09:38:25 -0700
changeset 13138 9a70fa2cc59c
parent 12997 7ad469d89bed
child 13139 917a5a5434a9
7145771: [macosx] CreateFont/Register.java test fails because of cached results of getAllFonts() Reviewed-by: igor, flar
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;
     }
 
 }