1620N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1620N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1620N/A *
1620N/A * This code is free software; you can redistribute it and/or modify it
1620N/A * under the terms of the GNU General Public License version 2 only, as
1620N/A * published by the Free Software Foundation.
1620N/A *
1620N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1620N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1620N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1620N/A * version 2 for more details (a copy is included in the LICENSE file that
1620N/A * accompanied this code).
1620N/A *
1620N/A * You should have received a copy of the GNU General Public License version
1620N/A * 2 along with this work; if not, write to the Free Software Foundation,
1620N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1620N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1620N/A */
1620N/A
1620N/A/* @test
1620N/A @bug 6824600
1620N/A @summary OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
1620N/A @author Pavel Porvatov
1620N/A @run main Test6824600
1620N/A*/
1620N/A
1620N/Aimport com.sun.java.swing.plaf.windows.DesktopProperty;
1620N/A
1620N/Aimport java.awt.*;
1620N/A
1620N/Apublic class Test6824600 {
1620N/A public static void main(String[] args) throws Exception {
1620N/A Toolkit toolkit = Toolkit.getDefaultToolkit();
1620N/A
1620N/A HackedDesktopProperty desktopProperty = new HackedDesktopProperty("Button.background", null);
1620N/A
1620N/A // Register listener in toolkit
1620N/A desktopProperty.getValueFromDesktop();
1620N/A
1620N/A int length = toolkit.getPropertyChangeListeners().length;
1620N/A
1620N/A // Make several invocations
1620N/A desktopProperty.getValueFromDesktop();
1620N/A desktopProperty.getValueFromDesktop();
1620N/A
1620N/A desktopProperty.invalidate();
1620N/A
1620N/A desktopProperty.getValueFromDesktop();
1620N/A desktopProperty.getValueFromDesktop();
1620N/A
1620N/A if (length != toolkit.getPropertyChangeListeners().length) {
1620N/A throw new RuntimeException("New listeners were added into Toolkit");
1620N/A }
1620N/A }
1620N/A
1620N/A public static class HackedDesktopProperty extends DesktopProperty {
1620N/A public HackedDesktopProperty(String key, Object fallback) {
1620N/A super(key, fallback);
1620N/A }
1620N/A
1620N/A // Publish the method
1620N/A public Object getValueFromDesktop() {
1620N/A return super.getValueFromDesktop();
1620N/A }
1620N/A }
1620N/A}