Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/PropertyEditor/Test6963811.java
41149 views
1
/*
2
* Copyright (c) 2010, 2015, 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
* @modules java.desktop/com.sun.beans.editors
30
* @compile -XDignore.symbol.file Test6963811.java
31
* @run main Test6963811
32
*/
33
34
import java.beans.PropertyEditorManager;
35
import com.sun.beans.editors.StringEditor;
36
37
public class Test6963811 implements Runnable {
38
private final long time;
39
private final boolean sync;
40
41
public Test6963811(long time, boolean sync) {
42
this.time = time;
43
this.sync = sync;
44
}
45
46
public void run() {
47
try {
48
Thread.sleep(this.time); // increase the chance of the deadlock
49
if (this.sync) {
50
synchronized (Test6963811.class) {
51
PropertyEditorManager.findEditor(Super.class);
52
}
53
}
54
else {
55
PropertyEditorManager.findEditor(Sub.class);
56
}
57
}
58
catch (Exception exception) {
59
exception.printStackTrace();
60
}
61
}
62
63
public static void main(String[] args) throws Exception {
64
Thread[] threads = new Thread[2];
65
for (int i = 0; i < threads.length; i++) {
66
threads[i] = new Thread(new Test6963811(0L, i > 0));
67
threads[i].start();
68
Thread.sleep(500L); // increase the chance of the deadlock
69
}
70
for (Thread thread : threads) {
71
thread.join();
72
}
73
}
74
75
public static class Super {
76
}
77
78
public static class Sub extends Super {
79
}
80
81
public static class SubEditor extends StringEditor {
82
public SubEditor() {
83
new Test6963811(1000L, true).run();
84
}
85
}
86
}
87
88