Mercurial > hg > graal-compiler
annotate test/compiler/6865031/Test.java @ 11790:70f43f67cdcb
StubForeignCallNode is not a DeoptimizingNode
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 25 Sep 2013 13:05:16 +0200 |
parents | c18cbe5936b8 |
children |
rev | line source |
---|---|
899
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
1 /* |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
2 * Copyright 2009 Goldman Sachs International. All Rights Reserved. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
4 * |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
8 * |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
13 * accompanied this code). |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
14 * |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
18 * |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
956
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
956
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
956
diff
changeset
|
21 * questions. |
899
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
22 * |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
23 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
24 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
25 /* |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
26 * @test |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
27 * @bug 6865031 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
28 * @summary Application gives bad result (throws bad exception) with compressed oops |
956
9a4e87ba1a90
6880533: test/compiler/6865031/Test.java miss -XX:+IgnoreUnrecognizedVMOptions
kvn
parents:
899
diff
changeset
|
29 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:HeapBaseMinAddress=32g -XX:-LoopUnswitching -XX:CompileCommand=inline,AbstractMemoryEfficientList.equals Test hello goodbye |
899
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
30 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
31 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
32 import java.lang.ref.ReferenceQueue; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
33 import java.lang.ref.WeakReference; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
34 import java.util.ArrayList; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
35 import java.util.Arrays; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
36 import java.util.List; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
37 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
38 interface MyList { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
39 public int size(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
40 public Object set(final int index, final Object element); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
41 public Object get(final int index); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
42 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
43 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
44 abstract class AbstractMemoryEfficientList implements MyList { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
45 abstract public int size(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
46 abstract public Object get(final int index); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
47 abstract public Object set(final int index, final Object element); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
48 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
49 public boolean equals(Object o) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
50 if (o == this) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
51 return true; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
52 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
53 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
54 if (!(o instanceof MyList)) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
55 return false; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
56 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
57 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
58 final MyList that = (MyList) o; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
59 if (this.size() != that.size()) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
60 return false; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
61 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
62 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
63 for (int i = 0; i < this.size(); i++) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
64 try { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
65 if (!((this.get(i)).equals(that.get(i)))) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
66 return false; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
67 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
68 } catch (IndexOutOfBoundsException e) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
69 System.out.println("THROWING RT EXC"); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
70 System.out.println("concurrent modification of this:" + this.getClass() + ":" + System.identityHashCode(this) + "; that:" + that.getClass() + ":" + System.identityHashCode(that) + "; i:" + i); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
71 e.printStackTrace(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
72 System.exit(97); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
73 throw new RuntimeException("concurrent modification of this:" + this.getClass() + ":" + System.identityHashCode(this) + "; that:" + that.getClass() + ":" + System.identityHashCode(that) + "; i:" + i, e); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
74 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
75 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
76 return true; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
77 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
78 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
79 public int hashCode() { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
80 int hashCode = 1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
81 for (int i = 0; i < this.size(); i++) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
82 Object obj = this.get(i); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
83 hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode()); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
84 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
85 return hashCode; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
86 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
87 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
88 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
89 final class SingletonList extends AbstractMemoryEfficientList { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
90 private Object element1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
91 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
92 SingletonList(final Object obj1) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
93 super(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
94 this.element1 = obj1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
95 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
96 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
97 public int size() { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
98 return 1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
99 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
100 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
101 public Object get(final int index) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
102 if (index == 0) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
103 return this.element1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
104 } else { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
105 throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + this.size()); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
106 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
107 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
108 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
109 public Object set(final int index, final Object element) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
110 if (index == 0) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
111 final Object previousElement = this.element1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
112 this.element1 = element; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
113 return previousElement; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
114 } else { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
115 throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + this.size()); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
116 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
117 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
118 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
119 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
120 final class DoubletonList extends AbstractMemoryEfficientList { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
121 private Object element1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
122 private Object element2; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
123 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
124 DoubletonList(final Object obj1, final Object obj2) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
125 this.element1 = obj1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
126 this.element2 = obj2; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
127 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
128 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
129 public int size() { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
130 return 2; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
131 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
132 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
133 public Object get(final int index) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
134 switch (index) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
135 case 0 : return this.element1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
136 case 1 : return this.element2; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
137 default: throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + this.size()); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
138 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
139 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
140 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
141 public Object set(final int index, final Object element) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
142 switch (index) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
143 case 0 : |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
144 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
145 final Object previousElement = this.element1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
146 this.element1 = element; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
147 return previousElement; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
148 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
149 case 1 : |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
150 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
151 final Object previousElement = this.element2; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
152 this.element2 = element; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
153 return previousElement; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
154 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
155 default : throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + this.size()); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
156 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
157 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
158 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
159 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
160 class WeakPool<V> { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
161 protected static final int DEFAULT_INITIAL_CAPACITY = 16; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
162 private static final int MAXIMUM_CAPACITY = 1 << 30; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
163 private static final float DEFAULT_LOAD_FACTOR = 0.75f; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
164 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
165 protected Entry<V>[] table; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
166 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
167 private int size; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
168 protected int threshold; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
169 private final float loadFactor; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
170 private final ReferenceQueue<V> queue = new ReferenceQueue<V>(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
171 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
172 public WeakPool() |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
173 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
174 this.loadFactor = DEFAULT_LOAD_FACTOR; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
175 threshold = DEFAULT_INITIAL_CAPACITY; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
176 table = new Entry[DEFAULT_INITIAL_CAPACITY]; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
177 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
178 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
179 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
180 * Check for equality of non-null reference x and possibly-null y. By |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
181 * default uses Object.equals. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
182 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
183 private boolean eq(Object x, Object y) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
184 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
185 return x == y || x.equals(y); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
186 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
187 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
188 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
189 * Return index for hash code h. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
190 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
191 private int indexFor(int h, int length) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
192 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
193 return h & length - 1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
194 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
195 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
196 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
197 * Expunge stale entries from the table. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
198 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
199 private void expungeStaleEntries() |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
200 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
201 Object r; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
202 while ((r = queue.poll()) != null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
203 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
204 Entry e = (Entry) r; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
205 int h = e.hash; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
206 int i = indexFor(h, table.length); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
207 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
208 // System.out.println("EXPUNGING " + h); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
209 Entry<V> prev = table[i]; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
210 Entry<V> p = prev; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
211 while (p != null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
212 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
213 Entry<V> next = p.next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
214 if (p == e) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
215 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
216 if (prev == e) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
217 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
218 table[i] = next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
219 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
220 else |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
221 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
222 prev.next = next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
223 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
224 e.next = null; // Help GC |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
225 size--; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
226 break; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
227 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
228 prev = p; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
229 p = next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
230 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
231 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
232 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
233 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
234 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
235 * Return the table after first expunging stale entries |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
236 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
237 private Entry<V>[] getTable() |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
238 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
239 expungeStaleEntries(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
240 return table; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
241 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
242 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
243 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
244 * Returns the number of key-value mappings in this map. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
245 * This result is a snapshot, and may not reflect unprocessed |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
246 * entries that will be removed before next attempted access |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
247 * because they are no longer referenced. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
248 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
249 public int size() |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
250 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
251 if (size == 0) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
252 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
253 return 0; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
254 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
255 expungeStaleEntries(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
256 return size; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
257 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
258 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
259 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
260 * Returns <tt>true</tt> if this map contains no key-value mappings. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
261 * This result is a snapshot, and may not reflect unprocessed |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
262 * entries that will be removed before next attempted access |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
263 * because they are no longer referenced. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
264 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
265 public boolean isEmpty() |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
266 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
267 return size() == 0; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
268 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
269 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
270 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
271 * Returns the value stored in the pool that equals the requested key |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
272 * or <tt>null</tt> if the map contains no mapping for |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
273 * this key (or the key is null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
274 * |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
275 * @param key the key whose equals value is to be returned. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
276 * @return the object that is equal the specified key, or |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
277 * <tt>null</tt> if key is null or no object in the pool equals the key. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
278 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
279 public V get(V key) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
280 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
281 if (key == null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
282 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
283 return null; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
284 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
285 int h = key.hashCode(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
286 Entry<V>[] tab = getTable(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
287 int index = indexFor(h, tab.length); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
288 Entry<V> e = tab[index]; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
289 while (e != null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
290 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
291 V candidate = e.get(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
292 if (e.hash == h && eq(key, candidate)) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
293 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
294 return candidate; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
295 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
296 e = e.next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
297 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
298 return null; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
299 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
300 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
301 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
302 * Returns the entry associated with the specified key in the HashMap. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
303 * Returns null if the HashMap contains no mapping for this key. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
304 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
305 Entry getEntry(Object key) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
306 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
307 int h = key.hashCode(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
308 Entry[] tab = getTable(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
309 int index = indexFor(h, tab.length); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
310 Entry e = tab[index]; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
311 while (e != null && !(e.hash == h && eq(key, e.get()))) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
312 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
313 e = e.next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
314 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
315 return e; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
316 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
317 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
318 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
319 * Places the object into the pool. If the object is null, nothing happens. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
320 * If an equal object already exists, it is not replaced. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
321 * |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
322 * @param key the object to put into the pool. key may be null. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
323 * @return the object in the pool that is equal to the key, or the newly placed key if no such object existed when put was called |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
324 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
325 public V put(V key) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
326 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
327 if (key == null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
328 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
329 return null; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
330 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
331 int h = key.hashCode(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
332 Entry<V>[] tab = getTable(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
333 int i = indexFor(h, tab.length); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
334 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
335 for (Entry<V> e = tab[i]; e != null; e = e.next) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
336 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
337 V candidate = e.get(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
338 if (h == e.hash && eq(key, candidate)) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
339 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
340 return candidate; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
341 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
342 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
343 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
344 tab[i] = new Entry<V>(key, queue, h, tab[i]); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
345 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
346 if (++size >= threshold) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
347 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
348 resize(tab.length * 2); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
349 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
350 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
351 // System.out.println("Added " + key + " to pool"); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
352 return key; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
353 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
354 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
355 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
356 * Rehashes the contents of this map into a new array with a |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
357 * larger capacity. This method is called automatically when the |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
358 * number of keys in this map reaches its threshold. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
359 * <p/> |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
360 * If current capacity is MAXIMUM_CAPACITY, this method does not |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
361 * resize the map, but but sets threshold to Integer.MAX_VALUE. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
362 * This has the effect of preventing future calls. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
363 * |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
364 * @param newCapacity the new capacity, MUST be a power of two; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
365 * must be greater than current capacity unless current |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
366 * capacity is MAXIMUM_CAPACITY (in which case value |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
367 * is irrelevant). |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
368 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
369 void resize(int newCapacity) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
370 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
371 Entry<V>[] oldTable = getTable(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
372 int oldCapacity = oldTable.length; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
373 if (oldCapacity == MAXIMUM_CAPACITY) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
374 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
375 threshold = Integer.MAX_VALUE; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
376 return; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
377 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
378 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
379 Entry<V>[] newTable = new Entry[newCapacity]; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
380 transfer(oldTable, newTable); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
381 table = newTable; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
382 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
383 /* |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
384 * If ignoring null elements and processing ref queue caused massive |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
385 * shrinkage, then restore old table. This should be rare, but avoids |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
386 * unbounded expansion of garbage-filled tables. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
387 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
388 if (size >= threshold / 2) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
389 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
390 threshold = (int) (newCapacity * loadFactor); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
391 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
392 else |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
393 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
394 expungeStaleEntries(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
395 transfer(newTable, oldTable); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
396 table = oldTable; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
397 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
398 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
399 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
400 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
401 * Transfer all entries from src to dest tables |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
402 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
403 private void transfer(Entry[] src, Entry[] dest) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
404 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
405 for (int j = 0; j < src.length; ++j) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
406 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
407 Entry e = src[j]; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
408 src[j] = null; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
409 while (e != null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
410 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
411 Entry next = e.next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
412 Object key = e.get(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
413 if (key == null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
414 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
415 e.next = null; // Help GC |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
416 size--; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
417 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
418 else |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
419 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
420 int i = indexFor(e.hash, dest.length); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
421 e.next = dest[i]; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
422 dest[i] = e; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
423 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
424 e = next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
425 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
426 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
427 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
428 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
429 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
430 * Removes the object in the pool that equals the key. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
431 * |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
432 * @param key |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
433 * @return previous value associated with specified key, or <tt>null</tt> |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
434 * if there was no mapping for key or the key is null. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
435 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
436 public V removeFromPool(V key) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
437 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
438 if (key == null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
439 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
440 return null; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
441 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
442 int h = key.hashCode(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
443 Entry<V>[] tab = getTable(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
444 int i = indexFor(h, tab.length); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
445 Entry<V> prev = tab[i]; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
446 Entry<V> e = prev; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
447 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
448 while (e != null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
449 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
450 Entry<V> next = e.next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
451 V candidate = e.get(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
452 if (h == e.hash && eq(key, candidate)) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
453 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
454 size--; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
455 if (prev == e) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
456 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
457 tab[i] = next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
458 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
459 else |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
460 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
461 prev.next = next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
462 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
463 return candidate; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
464 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
465 prev = e; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
466 e = next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
467 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
468 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
469 return null; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
470 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
471 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
472 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
473 * Removes all mappings from this map. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
474 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
475 public void clear() |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
476 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
477 // clear out ref queue. We don't need to expunge entries |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
478 // since table is getting cleared. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
479 while (queue.poll() != null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
480 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
481 // nop |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
482 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
483 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
484 table = new Entry[DEFAULT_INITIAL_CAPACITY]; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
485 threshold = DEFAULT_INITIAL_CAPACITY; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
486 size = 0; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
487 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
488 // Allocation of array may have caused GC, which may have caused |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
489 // additional entries to go stale. Removing these entries from the |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
490 // reference queue will make them eligible for reclamation. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
491 while (queue.poll() != null) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
492 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
493 // nop |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
494 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
495 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
496 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
497 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
498 * The entries in this hash table extend WeakReference, using its main ref |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
499 * field as the key. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
500 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
501 protected static class Entry<V> |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
502 extends WeakReference<V> |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
503 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
504 private final int hash; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
505 private Entry<V> next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
506 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
507 /** |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
508 * Create new entry. |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
509 */ |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
510 Entry(final V key, final ReferenceQueue<V> queue, final int hash, final Entry<V> next) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
511 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
512 super(key, queue); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
513 this.hash = hash; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
514 this.next = next; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
515 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
516 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
517 public V getKey() |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
518 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
519 return super.get(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
520 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
521 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
522 public boolean equals(Object o) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
523 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
524 if (!(o instanceof WeakPool.Entry)) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
525 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
526 return false; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
527 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
528 WeakPool.Entry<V> that = (WeakPool.Entry<V>) o; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
529 V k1 = this.getKey(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
530 V k2 = that.getKey(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
531 return (k1==k2 || k1.equals(k2)); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
532 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
533 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
534 public int hashCode() |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
535 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
536 return this.hash; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
537 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
538 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
539 public String toString() |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
540 { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
541 return String.valueOf(this.getKey()); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
542 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
543 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
544 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
545 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
546 final class MultiSynonymKey { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
547 private List<MyList> keys; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
548 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
549 public MultiSynonymKey() { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
550 keys = new ArrayList<MyList>(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
551 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
552 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
553 public MultiSynonymKey(MyList... arg) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
554 keys = Arrays.asList(arg); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
555 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
556 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
557 public List<MyList> getKeys() { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
558 return keys; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
559 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
560 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
561 public int hashCode() { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
562 return this.getKeys().hashCode(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
563 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
564 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
565 public boolean equals(Object obj) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
566 if (this == obj) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
567 return true; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
568 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
569 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
570 if (!(obj instanceof MultiSynonymKey)) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
571 return false; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
572 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
573 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
574 MultiSynonymKey that = (MultiSynonymKey) obj; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
575 return this.getKeys().equals(that.getKeys()); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
576 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
577 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
578 public String toString() { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
579 return this.getClass().getName() + this.getKeys().toString(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
580 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
581 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
582 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
583 public class Test extends Thread { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
584 static public Test test; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
585 static private byte[] arg1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
586 static private byte[] arg2; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
587 static public WeakPool<MultiSynonymKey> wp; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
588 public volatile MultiSynonymKey ml1; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
589 public volatile MultiSynonymKey ml2; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
590 private volatile MultiSynonymKey ml3; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
591 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
592 public void run() { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
593 int count=0; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
594 while (true) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
595 try { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
596 Thread.sleep(10); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
597 } catch (Exception e) {} |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
598 synchronized (wp) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
599 ml2 = new MultiSynonymKey(new DoubletonList(new String(arg1), new String(arg2))); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
600 wp.put(ml2); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
601 ml3 = new MultiSynonymKey(new DoubletonList(new String(arg1), new String(arg2))); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
602 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
603 try { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
604 Thread.sleep(10); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
605 } catch (Exception e) {} |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
606 synchronized (wp) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
607 ml1 = new MultiSynonymKey(new SingletonList(new String(arg1))); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
608 wp.put(ml1); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
609 ml3 = new MultiSynonymKey(new SingletonList(new String(arg1))); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
610 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
611 if (count++==100) |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
612 System.exit(95); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
613 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
614 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
615 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
616 public static void main(String[] args) throws Exception { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
617 wp = new WeakPool<MultiSynonymKey>(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
618 test = new Test(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
619 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
620 test.arg1 = args[0].getBytes(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
621 test.arg2 = args[1].getBytes(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
622 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
623 test.ml1 = new MultiSynonymKey(new SingletonList(new String(test.arg1))); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
624 test.ml2 = new MultiSynonymKey(new DoubletonList(new String(test.arg1), new String(test.arg2))); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
625 test.ml3 = new MultiSynonymKey(new DoubletonList(new String(test.arg1), new String(test.arg2))); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
626 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
627 wp.put(test.ml1); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
628 wp.put(test.ml2); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
629 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
630 test.setDaemon(true); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
631 test.start(); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
632 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
633 int counter = 0; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
634 while (true) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
635 synchronized (wp) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
636 MultiSynonymKey foo = test.ml3; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
637 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
638 if (wp.put(foo) == foo) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
639 // System.out.println("foo " + counter); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
640 // System.out.println(foo); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
641 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
642 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
643 counter++; |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
644 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
645 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
646 |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
647 private boolean eq(Object x, Object y) { |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
648 return x == y || x.equals(y); |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
649 } |
55cb84cd1247
6865031: Application gives bad result (throws bad exception) with compressed oops
kvn
parents:
diff
changeset
|
650 } |