Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/beans/PropertyEditor/Test6963811.java
47088 views
1
/*
2
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 6963811
27
* @summary Tests deadlock in PropertyEditorManager
28
* @author Sergey Malenkov
29
* @compile -XDignore.symbol.file Test6963811.java
30
* @run main Test6963811
31
*/
32
33
import java.beans.PropertyEditorManager;
34
import com.sun.beans.editors.StringEditor;
35
36
public class Test6963811 implements Runnable {
37
private final long time;
38
private final boolean sync;
39
40
public Test6963811(long time, boolean sync) {
41
this.time = time;
42
this.sync = sync;
43
}
44
45
public void run() {
46
try {
47
Thread.sleep(this.time); // increase the chance of the deadlock
48
if (this.sync) {
49
synchronized (Test6963811.class) {
50
PropertyEditorManager.findEditor(Super.class);
51
}
52
}
53
else {
54
PropertyEditorManager.findEditor(Sub.class);
55
}
56
}
57
catch (Exception exception) {
58
exception.printStackTrace();
59
}
60
}
61
62
public static void main(String[] args) throws Exception {
63
Thread[] threads = new Thread[2];
64
for (int i = 0; i < threads.length; i++) {
65
threads[i] = new Thread(new Test6963811(0L, i > 0));
66
threads[i].start();
67
Thread.sleep(500L); // increase the chance of the deadlock
68
}
69
for (Thread thread : threads) {
70
thread.join();
71
}
72
}
73
74
public static class Super {
75
}
76
77
public static class Sub extends Super {
78
}
79
80
public static class SubEditor extends StringEditor {
81
public SubEditor() {
82
new Test6963811(1000L, true).run();
83
}
84
}
85
}
86
87