test/jdk/java/io/Serializable/concurrentClassDescLookup/ConcurrentClassDescLookup.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
28 */ |
28 */ |
29 |
29 |
30 import java.io.*; |
30 import java.io.*; |
31 |
31 |
32 class Good implements Serializable { |
32 class Good implements Serializable { |
|
33 private static final long serialVersionUID = 6319710844400051132L; |
|
34 |
33 static { |
35 static { |
34 try { Thread.sleep(1000); } catch (InterruptedException ex) {} |
36 try { Thread.sleep(1000); } catch (InterruptedException ex) {} |
35 } |
37 } |
36 } |
38 } |
37 |
39 |
45 } |
47 } |
46 } |
48 } |
47 } |
49 } |
48 |
50 |
49 class SuccessfulLookup extends Thread { |
51 class SuccessfulLookup extends Thread { |
50 Class cl; |
52 Class<?> cl; |
51 long suid; |
53 long suid; |
52 Object barrier; |
54 Object barrier; |
53 boolean ok; |
55 boolean ok; |
54 |
56 |
55 SuccessfulLookup(Class cl, long suid, Object barrier) { |
57 SuccessfulLookup(Class<?> cl, long suid, Object barrier) { |
56 this.cl = cl; |
58 this.cl = cl; |
57 this.suid = suid; |
59 this.suid = suid; |
58 this.barrier = barrier; |
60 this.barrier = barrier; |
59 } |
61 } |
60 |
62 |
70 ok = true; |
72 ok = true; |
71 } |
73 } |
72 } |
74 } |
73 |
75 |
74 class FailingLookup extends Thread { |
76 class FailingLookup extends Thread { |
75 Class cl; |
77 Class<?> cl; |
76 Object barrier; |
78 final Object barrier; |
77 boolean ok; |
79 boolean ok; |
78 |
80 |
79 FailingLookup(Class cl, Object barrier) { |
81 FailingLookup(Class<?> cl, Object barrier) { |
80 this.cl = cl; |
82 this.cl = cl; |
81 this.barrier = barrier; |
83 this.barrier = barrier; |
82 } |
84 } |
83 |
85 |
84 public void run() { |
86 public void run() { |
97 } |
99 } |
98 |
100 |
99 public class ConcurrentClassDescLookup { |
101 public class ConcurrentClassDescLookup { |
100 public static void main(String[] args) throws Exception { |
102 public static void main(String[] args) throws Exception { |
101 ClassLoader loader = ConcurrentClassDescLookup.class.getClassLoader(); |
103 ClassLoader loader = ConcurrentClassDescLookup.class.getClassLoader(); |
102 Class cl = Class.forName("Good", false, loader); |
104 Class<?> cl = Class.forName("Good", false, loader); |
103 Object barrier = new Object(); |
105 Object barrier = new Object(); |
104 SuccessfulLookup[] slookups = new SuccessfulLookup[50]; |
106 SuccessfulLookup[] slookups = new SuccessfulLookup[50]; |
105 for (int i = 0; i < slookups.length; i++) { |
107 for (int i = 0; i < slookups.length; i++) { |
106 slookups[i] = |
108 slookups[i] = |
107 new SuccessfulLookup(cl, 6319710844400051132L, barrier); |
109 new SuccessfulLookup(cl, 6319710844400051132L, barrier); |