8163261: regression on Linux: java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java
Reviewed-by: serb, alexsch
--- 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");
}
}