43 |
|
} |
44 |
|
|
45 |
|
public void checkPackageAccess(AtomicReferenceFieldUpdaterTest obj) { |
46 |
< |
Integer one = new Integer(1); |
47 |
< |
Integer two = new Integer(2); |
46 |
> |
Item one = new Item(1); |
47 |
> |
Item two = new Item(2); |
48 |
|
obj.x = one; |
49 |
< |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest,Integer> a = |
49 |
> |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest,Item> a = |
50 |
|
AtomicReferenceFieldUpdater.newUpdater( |
51 |
< |
AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); |
51 |
> |
AtomicReferenceFieldUpdaterTest.class, Item.class, "x"); |
52 |
|
assertSame(one, a.get(obj)); |
53 |
|
assertTrue(a.compareAndSet(obj, one, two)); |
54 |
|
assertSame(two, a.get(obj)); |
162 |
|
} |
163 |
|
|
164 |
|
public void checkCompareAndSetProtectedSub() { |
165 |
< |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest,Integer> a = |
165 |
> |
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest,Item> a = |
166 |
|
AtomicReferenceFieldUpdater.newUpdater( |
167 |
|
AtomicReferenceFieldUpdaterTest.class, |
168 |
< |
Integer.class, "protectedField"); |
168 |
> |
Item.class, "protectedField"); |
169 |
|
this.protectedField = one; |
170 |
|
assertTrue(a.compareAndSet(this, one, two)); |
171 |
< |
assertTrue(a.compareAndSet(this, two, m4)); |
172 |
< |
assertSame(m4, a.get(this)); |
173 |
< |
assertFalse(a.compareAndSet(this, m5, seven)); |
171 |
> |
assertTrue(a.compareAndSet(this, two, minusFour)); |
172 |
> |
assertSame(minusFour, a.get(this)); |
173 |
> |
assertFalse(a.compareAndSet(this, minusFive, seven)); |
174 |
|
assertNotSame(seven, a.get(this)); |
175 |
< |
assertTrue(a.compareAndSet(this, m4, seven)); |
175 |
> |
assertTrue(a.compareAndSet(this, minusFour, seven)); |
176 |
|
assertSame(seven, a.get(this)); |
177 |
|
} |
178 |
|
} |