4900N/A/*
4900N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4900N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4900N/A *
4900N/A * This code is free software; you can redistribute it and/or modify it
4900N/A * under the terms of the GNU General Public License version 2 only, as
4900N/A * published by the Free Software Foundation.
4900N/A *
4900N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4900N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4900N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4900N/A * version 2 for more details (a copy is included in the LICENSE file that
4900N/A * accompanied this code).
4900N/A *
4900N/A * You should have received a copy of the GNU General Public License version
4900N/A * 2 along with this work; if not, write to the Free Software Foundation,
4900N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4900N/A *
4900N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4900N/A * or visit www.oracle.com if you need additional information or have any
4900N/A * questions.
4900N/A */
4900N/A
4900N/Aimport java.awt.image.ImageObserver;
4900N/Aimport java.awt.image.ImageProducer;
4900N/Aimport java.awt.image.ImageConsumer;
4900N/Aimport java.awt.Image;
4900N/Aimport java.awt.Container;
4900N/A
4900N/A/* @test 1.0 12/01/17
4900N/A @bug 7104151
4900N/A @summary Make sure that we don't leak image observers (or related objects)
4900N/A @run main/othervm AddNoLeak
4900N/A @author David Buck
4900N/A*/
4900N/A
4900N/Apublic class AddNoLeak {
4900N/A public static void main(String[] args) {
4900N/A System.setProperty("java.awt.headless", "true");
4900N/A Container cont = new Container();
4900N/A Image img = cont.createImage(new DummyImageSource());
4900N/A for(int i=0;i < 15000;i++) {
4900N/A img.getWidth(new ImageObserver() {
4900N/A public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {return false;}
4900N/A });
4900N/A if (i % 100 == 0) {
4900N/A System.gc();
4900N/A }
4900N/A }
4900N/A }
4900N/A
4900N/A private static class DummyImageSource implements ImageProducer {
4900N/A public void addConsumer(ImageConsumer ic){}
4900N/A public boolean isConsumer(ImageConsumer ic){return false;}
4900N/A public void removeConsumer(ImageConsumer ic){}
4900N/A public void startProduction(ImageConsumer ic){}
4900N/A public void requestTopDownLeftRightResend(ImageConsumer ic){}
4900N/A }
4900N/A}