Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/x509/AlgorithmId/OidTableInit.java
41153 views
1
/*
2
* Copyright (c) 2016 Google Inc. 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 8156584
27
* @modules java.base/sun.security.x509
28
* @summary AlgorithmId.get initialization thread safety
29
* @run main/othervm OidTableInit
30
*/
31
32
import java.util.ArrayList;
33
import java.util.concurrent.CountDownLatch;
34
import java.util.concurrent.ExecutorService;
35
import java.util.concurrent.Executors;
36
import java.util.concurrent.Future;
37
import sun.security.x509.AlgorithmId;
38
39
public class OidTableInit {
40
public static void main(String[] args) throws Throwable {
41
final String[] algorithmNames = {
42
"PBKDF2WITHHMACSHA1",
43
"PBEWITHMD5ANDDES",
44
"DSA",
45
"SHA384WITHRSA",
46
"RSA",
47
"SHA1WITHDSA",
48
"SHA512WITHRSA",
49
"MD2WITHRSA",
50
"PBEWITHSHA1ANDDESEDE",
51
"SHA1WITHRSA",
52
"DIFFIEHELLMAN",
53
"MD5WITHRSA",
54
"PBEWITHSHA1ANDRC2_40",
55
"SHA256WITHRSA",
56
};
57
58
final int THREADS = 2;
59
final ExecutorService pool = Executors.newFixedThreadPool(THREADS);
60
final CountDownLatch startingGate = new CountDownLatch(THREADS);
61
final Runnable r = new Runnable() { public void run() {
62
startingGate.countDown();
63
do {} while (startingGate.getCount() > 0);
64
try {
65
for (String algorithmName : algorithmNames)
66
AlgorithmId.get(algorithmName);
67
} catch (Throwable fail) {
68
throw new AssertionError(fail);
69
}
70
}};
71
final ArrayList<Future<?>> futures = new ArrayList<>();
72
for (int i = 0; i < THREADS; i++)
73
futures.add(pool.submit(r));
74
pool.shutdown();
75
for (Future<?> future : futures) future.get();
76
}
77
}
78
79