Mercurial > hg > graal-compiler
annotate test/compiler/7190310/Test7190310.java @ 11013:f822ecf621ce
Merge
author | chegar |
---|---|
date | Sun, 28 Apr 2013 08:15:33 +0100 |
parents | bf623b2d5508 |
children |
rev | line source |
---|---|
6615
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
1 /* |
7606
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
6615
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
4 * |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
8 * |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
13 * accompanied this code). |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
14 * |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
18 * |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
21 * questions. |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
22 * |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
23 */ |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
24 |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
25 /* |
7606
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
26 * @test |
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
27 * @bug 7190310 |
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
28 * @summary Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops |
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
29 * @run main/othervm/timeout=600 -Xbatch Test7190310 |
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
30 */ |
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
31 |
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
32 /* |
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
33 * Note bug exhibits as infinite loop, timeout is helpful. |
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
34 * It should normally finish pretty quickly, but on some especially slow machines |
bf623b2d5508
8006204: please JTREGify test/compiler/7190310/Test7190310.java
kvn
parents:
6615
diff
changeset
|
35 * it may not. The companion _unsafe test lacks a timeout, but that is okay. |
6615
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
36 */ |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
37 |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
38 import java.lang.ref.*; |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
39 |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
40 public class Test7190310 { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
41 private static Object str = new Object() { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
42 public String toString() { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
43 return "The Object"; |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
44 } |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
45 |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
46 protected void finalize() throws Throwable { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
47 System.out.println("The Object is being finalized"); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
48 super.finalize(); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
49 } |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
50 }; |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
51 private final static ReferenceQueue<Object> rq = |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
52 new ReferenceQueue<Object>(); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
53 private final static WeakReference<Object> wr = |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
54 new WeakReference<Object>(str, rq); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
55 |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
56 public static void main(String[] args) |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
57 throws InterruptedException { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
58 Thread reader = new Thread() { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
59 public void run() { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
60 while (wr.get() != null) { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
61 } |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
62 System.out.println("wr.get() returned null"); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
63 } |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
64 }; |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
65 |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
66 Thread queueReader = new Thread() { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
67 public void run() { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
68 try { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
69 Reference<? extends Object> ref = rq.remove(); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
70 System.out.println(ref); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
71 System.out.println("queueReader returned, ref==wr is " |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
72 + (ref == wr)); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
73 } catch (InterruptedException e) { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
74 System.err.println("Sleep interrupted - exiting"); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
75 } |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
76 } |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
77 }; |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
78 |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
79 reader.start(); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
80 queueReader.start(); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
81 |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
82 Thread.sleep(1000); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
83 str = null; |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
84 System.gc(); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
85 } |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
86 } |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
diff
changeset
|
87 |