2535N/A/*
2535N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2535N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2535N/A *
2535N/A * This code is free software; you can redistribute it and/or modify it
2535N/A * under the terms of the GNU General Public License version 2 only, as
2535N/A * published by the Free Software Foundation.
2535N/A *
2535N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2535N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2535N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2535N/A * version 2 for more details (a copy is included in the LICENSE file that
2535N/A * accompanied this code).
2535N/A *
2535N/A * You should have received a copy of the GNU General Public License version
2535N/A * 2 along with this work; if not, write to the Free Software Foundation,
2535N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2535N/A *
2535N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2535N/A * or visit www.oracle.com if you need additional information or have any
2535N/A * questions.
2535N/A */
2535N/A
2535N/A/*
2535N/A * @test
2535N/A * @bug 6963811
2535N/A * @summary Tests deadlock in Introspector
2535N/A * @author Sergey Malenkov
2535N/A */
2535N/A
2535N/Aimport java.beans.Introspector;
2535N/Aimport java.beans.SimpleBeanInfo;
2535N/A
2535N/Apublic class Test6963811 implements Runnable {
2535N/A private final long time;
2535N/A private final boolean sync;
2535N/A
2535N/A public Test6963811(long time, boolean sync) {
2535N/A this.time = time;
2535N/A this.sync = sync;
2535N/A }
2535N/A
2535N/A public void run() {
2535N/A try {
2535N/A Thread.sleep(this.time); // increase the chance of the deadlock
2535N/A Introspector.getBeanInfo(
2535N/A this.sync ? Super.class : Sub.class,
2535N/A this.sync ? null : Object.class);
2535N/A }
2535N/A catch (Exception exception) {
2535N/A exception.printStackTrace();
2535N/A }
2535N/A }
2535N/A
2535N/A public static void main(String[] args) throws Exception {
2535N/A Thread[] threads = new Thread[2];
2535N/A for (int i = 0; i < threads.length; i++) {
2535N/A threads[i] = new Thread(new Test6963811(0L, i > 0));
2535N/A threads[i].start();
2535N/A Thread.sleep(500L); // increase the chance of the deadlock
2535N/A }
2535N/A for (Thread thread : threads) {
2535N/A thread.join();
2535N/A }
2535N/A }
2535N/A
2535N/A public static class Super {
2535N/A }
2535N/A
2535N/A public static class Sub extends Super {
2535N/A }
2535N/A
2535N/A public static class SubBeanInfo extends SimpleBeanInfo {
2535N/A public SubBeanInfo() {
2535N/A new Test6963811(1000L, true).run();
2535N/A }
2535N/A }
2535N/A}