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

Comparing jsr166/src/test/tck/ThreadLocalRandomTest.java (file contents):
Revision 1.22 by jsr166, Sun Nov 13 03:36:50 2016 UTC vs.
Revision 1.23 by jsr166, Fri Dec 9 06:56:30 2016 UTC

# Line 58 | Line 58 | public class ThreadLocalRandomTest exten
58       */
59      public void testNext() throws ReflectiveOperationException {
60          ThreadLocalRandom rnd = ThreadLocalRandom.current();
61 +        final java.lang.reflect.Method m;
62          try {
63 <            java.lang.reflect.Method m
63 <                = ThreadLocalRandom.class.getDeclaredMethod(
63 >            m = ThreadLocalRandom.class.getDeclaredMethod(
64                      "next", new Class[] { int.class });
65              m.setAccessible(true);
66 +        } catch (SecurityException
67 +                 | java.lang.reflect.InaccessibleObjectException acceptable) {
68 +            // Either jdk9 module system or security manager might deny access.
69 +            return;
70 +        }
71  
72 <            int i;
73 <            {
74 <                int val = new java.util.Random().nextInt(4);
75 <                for (i = 0; i < NCALLS; i++) {
76 <                    int q = (int) m.invoke(rnd, new Object[] { 2 });
77 <                    if (val == q) break;
73 <                }
74 <                assertTrue(i < NCALLS);
72 >        int i;
73 >        {
74 >            int val = new java.util.Random().nextInt(4);
75 >            for (i = 0; i < NCALLS; i++) {
76 >                int q = (int) m.invoke(rnd, new Object[] { 2 });
77 >                if (val == q) break;
78              }
79 +            assertTrue(i < NCALLS);
80 +        }
81  
82 <            {
83 <                int r = (int) m.invoke(rnd, new Object[] { 3 });
84 <                for (i = 0; i < NCALLS; i++) {
85 <                    int q = (int) m.invoke(rnd, new Object[] { 3 });
86 <                    assertTrue(q < (1<<3));
87 <                    if (r != q) break;
83 <                }
84 <                assertTrue(i < NCALLS);
82 >        {
83 >            int r = (int) m.invoke(rnd, new Object[] { 3 });
84 >            for (i = 0; i < NCALLS; i++) {
85 >                int q = (int) m.invoke(rnd, new Object[] { 3 });
86 >                assertTrue(q < (1<<3));
87 >                if (r != q) break;
88              }
89 <        } catch (SecurityException acceptable) {}
89 >            assertTrue(i < NCALLS);
90 >        }
91      }
92  
93      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines