ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AtomicLongFieldUpdaterTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AtomicLongFieldUpdaterTest.java (file contents):
Revision 1.30 by dl, Sun Nov 8 15:34:01 2015 UTC vs.
Revision 1.31 by jsr166, Mon Nov 9 07:54:28 2015 UTC

# Line 52 | Line 52 | public class AtomicLongFieldUpdaterTest
52      }
53  
54      static class UnrelatedClass {
55 <        public void checkPrivateAccess() {
56 <            Exception ex = null;
55 >        public void checkPackageAccess(AtomicLongFieldUpdaterTest obj) {
56 >            obj.x = 72L;
57 >            AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a =
58 >                AtomicLongFieldUpdater.newUpdater
59 >                (AtomicLongFieldUpdaterTest.class, "x");
60 >            assertEquals(72L, a.get(obj));
61 >            assertTrue(a.compareAndSet(obj, 72L, 73L));
62 >            assertEquals(73L, a.get(obj));
63 >        }
64 >
65 >        public void checkPrivateAccess(AtomicLongFieldUpdaterTest obj) {
66              try {
67                  AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a =
68                      AtomicLongFieldUpdater.newUpdater
69 <                    (AtomicLongFieldUpdaterTest.class, "x");
70 <            } catch (RuntimeException rex) {
71 <                ex = rex;
69 >                    (AtomicLongFieldUpdaterTest.class, "privateField");
70 >                throw new AssertionError("should throw");
71 >            } catch (RuntimeException success) {
72 >                assertNotNull(success.getCause());
73              }
64            if (ex != null) throw new Error();
74          }
75      }
76  
# Line 112 | Line 121 | public class AtomicLongFieldUpdaterTest
121      }
122  
123      /**
124 <     * construction from unrelated class throws RuntimeException
124 >     * construction from unrelated class; package access is allowed,
125 >     * private access is not
126       */
127      public void testUnrelatedClassAccess() {
128 <        UnrelatedClass s = new UnrelatedClass();
129 <        s.checkPrivateAccess();
128 >        new UnrelatedClass().checkPackageAccess(this);
129 >        new UnrelatedClass().checkPrivateAccess(this);
130      }
131  
132      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines