1510N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1510N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1510N/A *
1510N/A * This code is free software; you can redistribute it and/or modify it
1510N/A * under the terms of the GNU General Public License version 2 only, as
1510N/A * published by the Free Software Foundation.
1510N/A *
1510N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1510N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1510N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1510N/A * version 2 for more details (a copy is included in the LICENSE file that
1510N/A * accompanied this code).
1510N/A *
1510N/A * You should have received a copy of the GNU General Public License version
1510N/A * 2 along with this work; if not, write to the Free Software Foundation,
1510N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1510N/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.
1510N/A */
1510N/A
1510N/A/*
1510N/A * @test
1510N/A * @bug 6660049 6849518
1510N/A * @summary Tests the Region initialization
1510N/A * @author Sergey Malenkov
1510N/A */
1510N/A
1510N/Aimport sun.awt.SunToolkit;
1510N/A
1510N/Aimport javax.swing.JButton;
1510N/Aimport javax.swing.JComponent;
1510N/Aimport javax.swing.SwingUtilities;
1510N/Aimport javax.swing.plaf.synth.Region;
1510N/Aimport javax.swing.plaf.synth.SynthLookAndFeel;
1510N/A
1510N/Apublic class Test6660049 implements Runnable {
1510N/A public static void main(String[] args) {
1510N/A SwingUtilities.invokeLater(new Test6660049(
1510N/A javax.swing.JButton.class,
1510N/A javax.swing.JCheckBox.class,
1510N/A javax.swing.JCheckBoxMenuItem.class,
1510N/A javax.swing.JColorChooser.class,
1510N/A javax.swing.JComboBox.class,
1510N/A javax.swing.JDesktopPane.class,
1510N/A javax.swing.JEditorPane.class,
1510N/A javax.swing.JFileChooser.class,
1510N/A javax.swing.JFormattedTextField.class,
1510N/A javax.swing.JInternalFrame.class,
1510N/A javax.swing.JLabel.class,
1510N/A javax.swing.JList.class,
1510N/A javax.swing.JMenu.class,
1510N/A javax.swing.JMenuBar.class,
1510N/A javax.swing.JMenuItem.class,
1510N/A javax.swing.JOptionPane.class,
1510N/A javax.swing.JPanel.class,
1510N/A javax.swing.JPasswordField.class,
1510N/A javax.swing.JPopupMenu.class,
1510N/A javax.swing.JProgressBar.class,
1510N/A javax.swing.JRadioButton.class,
1510N/A javax.swing.JRadioButtonMenuItem.class,
1510N/A javax.swing.JRootPane.class,
1510N/A javax.swing.JScrollBar.class,
1510N/A javax.swing.JScrollPane.class,
1510N/A javax.swing.JSeparator.class,
1510N/A javax.swing.JSlider.class,
1510N/A javax.swing.JSpinner.class,
1510N/A javax.swing.JSplitPane.class,
1510N/A javax.swing.JTabbedPane.class,
1510N/A javax.swing.JTable.class,
1510N/A javax.swing.JTextArea.class,
1510N/A javax.swing.JTextField.class,
1510N/A javax.swing.JTextPane.class,
1510N/A javax.swing.JToggleButton.class,
1510N/A javax.swing.JToolBar.class,
1510N/A javax.swing.JToolTip.class,
1510N/A javax.swing.JTree.class,
1510N/A javax.swing.JViewport.class,
1510N/A javax.swing.table.JTableHeader.class));
1510N/A }
1510N/A
1510N/A private final Class<? extends JComponent>[] types;
1510N/A private final Region region;
1510N/A
1510N/A private Test6660049(Class<? extends JComponent>... types) {
1510N/A this.types = types;
1510N/A run();
1510N/A
1510N/A this.region = new Region("Button", "ButtonUI", true) {
1510N/A @Override
1510N/A public String getName() {
1510N/A throw new Error("6660049: exploit is available");
1510N/A }
1510N/A };
1510N/A }
1510N/A
1510N/A public void run() {
1510N/A if (this.region != null) {
1510N/A SunToolkit.createNewAppContext();
1510N/A }
1510N/A for (Class<? extends JComponent> type : this.types) {
1510N/A Region region = getRegion(type);
1510N/A if (region == null) {
1510N/A throw new Error("6849518: region is not initialized");
1510N/A }
1510N/A }
1510N/A getRegion(JButton.class).getName();
1510N/A }
1510N/A
1510N/A private static Region getRegion(Class<? extends JComponent> type) {
1510N/A try {
1510N/A return SynthLookAndFeel.getRegion(type.newInstance());
1510N/A }
1510N/A catch (IllegalAccessException exception) {
1510N/A throw new Error("unexpected exception", exception);
1510N/A }
1510N/A catch (InstantiationException exception) {
1510N/A throw new Error("unexpected exception", exception);
1510N/A }
1510N/A }
1510N/A}