8163261: regression on Linux: java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java
authorarapte
Tue, 20 Sep 2016 11:46:34 +0530
changeset 41389 21cd852c2b60
parent 41388 1a4a7fe92ac6
child 41390 a50c1f9c2244
8163261: regression on Linux: java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java Reviewed-by: serb, alexsch
jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java
jdk/test/java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java
--- a/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java	Mon Sep 19 13:12:28 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java	Tue Sep 20 11:46:34 2016 +0530
@@ -25,7 +25,6 @@
 package sun.swing;
 
 import java.awt.*;
-import java.awt.geom.AffineTransform;
 import java.awt.image.*;
 import java.util.*;
 
@@ -60,7 +59,11 @@
         synchronized(CachedPainter.class) {
             ImageCache cache = cacheMap.get(key);
             if (cache == null) {
-                cache = new ImageCache(1);
+                if (key == PainterMultiResolutionCachedImage.class) {
+                    cache = new ImageCache(32);
+                } else {
+                    cache = new ImageCache(1);
+                }
                 cacheMap.put(key, cache);
             }
             return cache;
@@ -271,7 +274,8 @@
         public Image getResolutionVariant(double destWidth, double destHeight) {
             int w = (int) Math.ceil(destWidth);
             int h = (int) Math.ceil(destHeight);
-            return getImage(this, c, baseWidth, baseHeight, w, h, args);
+            return getImage(PainterMultiResolutionCachedImage.class,
+                    c, baseWidth, baseHeight, w, h, args);
         }
 
         @Override
--- a/jdk/test/java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java	Mon Sep 19 13:12:28 2016 -0700
+++ b/jdk/test/java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java	Tue Sep 20 11:46:34 2016 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 /*
  @test
  @key headful
- @bug 7079254
+ @bug 7079254 8163261
  @summary Toolkit eventListener leaks memory
  @library ../regtesthelpers
  @build Util
@@ -93,8 +93,15 @@
             }
         }
         alloc = null;
+        String leakObjs = "";
         if (button.get() != null) {
-            throw new Exception("Test failed: JButton was not collected");
+            leakObjs = "JButton";
+        }
+        if (p.get() != null) {
+            leakObjs += " JPanel";
+        }
+        if (leakObjs != "") {
+            throw new Exception("Test failed: " + leakObjs + " not collected");
         }
     }