changeset 97:8c4495a44ffa

Migrate atomicity.(buffers|crosscache).* tests to new API.
author shade
date Thu, 13 Mar 2014 23:39:28 +0400
parents 10286c3a6e62
children dc6ce8b3a255
files tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/ByteBufferViewsAtomicityTests.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/CharBufferAtomicityTests.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/DirectByteBufferAtomicityTests.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/DirectByteBufferViewsAtomicityTests.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/DoubleBufferAtomicityTests.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/FloatBufferAtomicityTests.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/IntBufferAtomicityTests.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/LongBufferAtomicityTests.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/ShortBufferAtomicityTests.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/crosscache/ByteBufferIntAtomicityTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/crosscache/DirectByteBufferIntAtomicityTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/crosscache/UnsafeIntAtomicityTest.java
diffstat 12 files changed, 318 insertions(+), 242 deletions(-) [+]
line wrap: on
line diff
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/ByteBufferViewsAtomicityTests.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/ByteBufferViewsAtomicityTests.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,6 +24,9 @@
  */
 package org.openjdk.jcstress.tests.atomicity.buffers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult1;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
@@ -38,48 +41,62 @@
 
 public class ByteBufferViewsAtomicityTests {
 
-    public static ByteBuffer order(ByteBuffer b) { b.order(ByteOrder.nativeOrder()); return b; }
+    @State
+    public static class MyState {
+        private final ByteBuffer b;
+        private final IntBuffer ib;
+        private final CharBuffer cb;
+        private final DoubleBuffer db;
+        private final FloatBuffer fb;
+        private final LongBuffer lb;
+        private final ShortBuffer sb;
 
-    public static class IntViewTest implements Actor2_Test<IntBuffer, LongResult1> {
-        @Override public IntBuffer newState()                        { return order(ByteBuffer.allocate(16)).asIntBuffer(); }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                         }
-        @Override public void actor1(IntBuffer b, LongResult1 r)     { b.put(0, -1);                                     }
-        @Override public void actor2(IntBuffer b, LongResult1 r)     { r.r1 = b.get(0);                                  }
+        public MyState() {
+            b = ByteBuffer.allocate(16);
+            b.order(ByteOrder.nativeOrder());
+            ib = b.asIntBuffer();
+            cb = b.asCharBuffer();
+            db = b.asDoubleBuffer();
+            fb = b.asFloatBuffer();
+            lb = b.asLongBuffer();
+            sb = b.asShortBuffer();
+        }
     }
 
-    public static class CharViewTest implements Actor2_Test<CharBuffer, LongResult1> {
-        @Override public CharBuffer newState()                       { return order(ByteBuffer.allocate(16)).asCharBuffer();    }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                         }
-        @Override public void actor1(CharBuffer b, LongResult1 r)    { b.put(0, 'a');                                    }
-        @Override public void actor2(CharBuffer b, LongResult1 r)    { r.r1 = b.get(0);                                  }
+    @ConcurrencyStressTest
+    public static class IntViewTest {
+        @Actor public void actor1(MyState s)                { s.ib.put(0, -1);                                  }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.ib.get(0);                               }
     }
 
-    public static class DoubleViewTest implements Actor2_Test<DoubleBuffer, LongResult1> {
-        @Override public DoubleBuffer newState()                     { return order(ByteBuffer.allocate(16)).asDoubleBuffer();  }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                         }
-        @Override public void actor1(DoubleBuffer b, LongResult1 r)  { b.put(0, -1D);                                    }
-        @Override public void actor2(DoubleBuffer b, LongResult1 r)  { r.r1 = Double.doubleToRawLongBits(b.get(0));      }
+    @ConcurrencyStressTest
+    public static class CharViewTest {
+        @Actor public void actor1(MyState s)                { s.cb.put(0, 'a');                                 }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.cb.get(0);                               }
     }
 
-    public static class FloatViewTest implements Actor2_Test<FloatBuffer, LongResult1> {
-        @Override public FloatBuffer newState()                      { return order(ByteBuffer.allocate(16)).asFloatBuffer();   }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                         }
-        @Override public void actor1(FloatBuffer b, LongResult1 r)   { b.put(0, -1F);                                    }
-        @Override public void actor2(FloatBuffer b, LongResult1 r)   { r.r1 = Float.floatToRawIntBits(b.get(0));         }
+    @ConcurrencyStressTest
+    public static class DoubleViewTest {
+        @Actor public void actor1(MyState s)                { s.db.put(0, -1D);                                 }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = Double.doubleToRawLongBits(s.db.get(0));   }
     }
 
-    public static class LongViewTest implements Actor2_Test<LongBuffer, LongResult1> {
-        @Override public LongBuffer newState()                       { return order(ByteBuffer.allocate(16)).asLongBuffer();    }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                         }
-        @Override public void actor1(LongBuffer b, LongResult1 r)    { b.put(0, -1);                                     }
-        @Override public void actor2(LongBuffer b, LongResult1 r)    { r.r1 = b.get(0);                                  }
+    @ConcurrencyStressTest
+    public static class FloatViewTest {
+        @Actor public void actor1(MyState s)                { s.fb.put(0, -1F);                                 }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = Float.floatToRawIntBits(s.fb.get(0));      }
     }
 
-    public static class ShortViewTest implements Actor2_Test<ShortBuffer, LongResult1> {
-        @Override public ShortBuffer newState()                      { return order(ByteBuffer.allocate(16)).asShortBuffer();   }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                         }
-        @Override public void actor1(ShortBuffer b, LongResult1 r)   { b.put(0, (short) -1);                             }
-        @Override public void actor2(ShortBuffer b, LongResult1 r)   { r.r1 = b.get(0);                                  }
+    @ConcurrencyStressTest
+    public static class LongViewTest {
+        @Actor public void actor1(MyState s)                { s.lb.put(0, -1);                                  }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.lb.get(0);                               }
+    }
+
+    @ConcurrencyStressTest
+    public static class ShortViewTest {
+        @Actor public void actor1(MyState s)                { s.sb.put(0, (short) -1);                          }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.sb.get(0);                               }
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/CharBufferAtomicityTests.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/CharBufferAtomicityTests.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,21 +24,31 @@
  */
 package org.openjdk.jcstress.tests.atomicity.buffers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult1;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 import java.nio.CharBuffer;
 
 public class CharBufferAtomicityTests {
 
-    public abstract static class CharBufferTest implements Actor2_Test<CharBuffer, LongResult1> {
-        @Override public CharBuffer newState()                { return CharBuffer.allocate(16);                     }
-        @Override public LongResult1 newResult()              { return new LongResult1();                           }
+    @State
+    public static class MyState {
+        private final CharBuffer b;
+
+        public MyState() {
+            b = CharBuffer.allocate(16);
+        }
     }
 
-    public static class CharTest extends CharBufferTest {
-        @Override public void actor1(CharBuffer b, LongResult1 r) { b.put(0, 'a');                                      }
-        @Override public void actor2(CharBuffer b, LongResult1 r) { r.r1 = b.get();                                     }
+    @ConcurrencyStressTest
+    public static class CharTest {
+        @Actor public void actor1(MyState s)                { s.b.put(0, 'a');                                      }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.b.get();                                     }
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/DirectByteBufferAtomicityTests.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/DirectByteBufferAtomicityTests.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,6 +24,9 @@
  */
 package org.openjdk.jcstress.tests.atomicity.buffers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult1;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
@@ -32,46 +35,50 @@
 
 public class DirectByteBufferAtomicityTests {
 
-    public static ByteBuffer order(ByteBuffer b) { b.order(ByteOrder.nativeOrder()); return b; }
+    @State
+    public static class MyState {
+        private final ByteBuffer b;
 
-    public abstract static class ByteBufferTest implements Actor2_Test<ByteBuffer, LongResult1> {
-        @Override public ByteBuffer newState()                { return order(ByteBuffer.allocateDirect(16));        }
-        @Override public LongResult1 newResult()              { return new LongResult1();                           }
+        public MyState() {
+            b = ByteBuffer.allocateDirect(16);
+            b.order(ByteOrder.nativeOrder());
+        }
     }
 
-    public static class IntTest extends ByteBufferTest {
-        @Override public synchronized void actor1(ByteBuffer b, LongResult1 r)  { b.putInt(0, -1);                                    }
-        @Override public synchronized void actor2(ByteBuffer b, LongResult1 r)  { r.r1 = b.getInt(0);                                 }
+    @ConcurrencyStressTest
+    public static class IntTest {
+        @Actor public void actor1(MyState s)                 { s.b.putInt(0, -1);                                    }
+        @Actor public void actor2(MyState s, LongResult1 r)  { r.r1 = s.b.getInt(0);                                 }
     }
 
-    public static class ShortTest extends ByteBufferTest {
-        @Override public void actor1(ByteBuffer b, LongResult1 r)  { b.putShort(0, (short) -1);                          }
-        @Override public void actor2(ByteBuffer b, LongResult1 r)  { r.r1 = b.getShort(0);                               }
+    public static class ShortTest {
+        @Actor public void actor1(MyState s, LongResult1 r)  { s.b.putShort(0, (short) -1);                          }
+        @Actor public void actor2(MyState s, LongResult1 r)  { r.r1 = s.b.getShort(0);                               }
     }
 
-    public static class CharTest extends ByteBufferTest {
-        @Override public void actor1(ByteBuffer b, LongResult1 r)  { b.putChar(0, 'a');                                  }
-        @Override public void actor2(ByteBuffer b, LongResult1 r)  { r.r1 = b.getChar(0);                                }
+    public static class CharTest {
+        @Actor public void actor1(MyState s, LongResult1 r)  { s.b.putChar(0, 'a');                                  }
+        @Actor public void actor2(MyState s, LongResult1 r)  { r.r1 = s.b.getChar(0);                                }
     }
 
-    public static class LongTest extends ByteBufferTest {
-        @Override public void actor1(ByteBuffer b, LongResult1 r)  { b.putLong(0, -1L);                                  }
-        @Override public void actor2(ByteBuffer b, LongResult1 r)  { r.r1 = b.getLong(0);                                }
+    public static class LongTest {
+        @Actor public void actor1(MyState s, LongResult1 r)  { s.b.putLong(0, -1L);                                  }
+        @Actor public void actor2(MyState s, LongResult1 r)  { r.r1 = s.b.getLong(0);                                }
     }
 
-    public static class DoubleTest extends ByteBufferTest {
-        @Override public void actor1(ByteBuffer b, LongResult1 r)  { b.putDouble(0, -1D);                                }
-        @Override public void actor2(ByteBuffer b, LongResult1 r)  { r.r1 = Double.doubleToRawLongBits(b.getDouble(0));  }
+    public static class DoubleTest {
+        @Actor public void actor1(MyState s, LongResult1 r)  { s.b.putDouble(0, -1D);                                }
+        @Actor public void actor2(MyState s, LongResult1 r)  { r.r1 = Double.doubleToRawLongBits(s.b.getDouble(0));  }
     }
 
-    public static class FloatTest extends ByteBufferTest {
-        @Override public void actor1(ByteBuffer b, LongResult1 r)  { b.putFloat(0, -1F);                                 }
-        @Override public void actor2(ByteBuffer b, LongResult1 r)  { r.r1 = Float.floatToRawIntBits(b.getFloat(0));      }
+    public static class FloatTest {
+        @Actor public void actor1(MyState s, LongResult1 r)  { s.b.putFloat(0, -1F);                                 }
+        @Actor public void actor2(MyState s, LongResult1 r)  { r.r1 = Float.floatToRawIntBits(s.b.getFloat(0));      }
     }
 
-    public static class ByteTest extends ByteBufferTest {
-        @Override public void actor1(ByteBuffer b, LongResult1 r)  { b.put(0, (byte) -1);                                }
-        @Override public void actor2(ByteBuffer b, LongResult1 r)  { r.r1 = b.get();                                     }
+    public static class ByteTest {
+        @Actor public void actor1(MyState s, LongResult1 r)  { s.b.put(0, (byte) -1);                                }
+        @Actor public void actor2(MyState s, LongResult1 r)  { r.r1 = s.b.get();                                     }
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/DirectByteBufferViewsAtomicityTests.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/DirectByteBufferViewsAtomicityTests.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,6 +24,9 @@
  */
 package org.openjdk.jcstress.tests.atomicity.buffers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult1;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
@@ -38,48 +41,62 @@
 
 public class DirectByteBufferViewsAtomicityTests {
 
-    public static ByteBuffer order(ByteBuffer b) { b.order(ByteOrder.nativeOrder()); return b; }
+    @State
+    public static class MyState {
+        private final ByteBuffer b;
+        private final IntBuffer ib;
+        private final CharBuffer cb;
+        private final DoubleBuffer db;
+        private final FloatBuffer fb;
+        private final LongBuffer lb;
+        private final ShortBuffer sb;
 
-    public static class IntViewTest implements Actor2_Test<IntBuffer, LongResult1> {
-        @Override public IntBuffer newState()                        { return order(ByteBuffer.allocateDirect(16)).asIntBuffer();     }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                          }
-        @Override public void actor1(IntBuffer b, LongResult1 r)     { b.put(0, -1);                                     }
-        @Override public void actor2(IntBuffer b, LongResult1 r)     { r.r1 = b.get(0);                                  }
+        public MyState() {
+            b = ByteBuffer.allocate(16);
+            b.order(ByteOrder.nativeOrder());
+            ib = b.asIntBuffer();
+            cb = b.asCharBuffer();
+            db = b.asDoubleBuffer();
+            fb = b.asFloatBuffer();
+            lb = b.asLongBuffer();
+            sb = b.asShortBuffer();
+        }
     }
 
-    public static class CharViewTest implements Actor2_Test<CharBuffer, LongResult1> {
-        @Override public CharBuffer newState()                  { return order(ByteBuffer.allocateDirect(16)).asCharBuffer();    }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                          }
-        @Override public void actor1(CharBuffer b, LongResult1 r)    { b.put(0, 'a');                                     }
-        @Override public void actor2(CharBuffer b, LongResult1 r)    { r.r1 = b.get(0);                                   }
+    @ConcurrencyStressTest
+    public static class IntViewTest {
+        @Actor public void actor1(MyState s)                { s.ib.put(0, -1);                                  }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.ib.get(0);                               }
     }
 
-    public static class DoubleViewTest implements Actor2_Test<DoubleBuffer, LongResult1> {
-        @Override public DoubleBuffer newState()                { return order(ByteBuffer.allocateDirect(16)).asDoubleBuffer();  }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                          }
-        @Override public void actor1(DoubleBuffer b, LongResult1 r)  { b.put(0, -1D);                                     }
-        @Override public void actor2(DoubleBuffer b, LongResult1 r)  { r.r1 = Double.doubleToRawLongBits(b.get(0));       }
+    @ConcurrencyStressTest
+    public static class CharViewTest {
+        @Actor public void actor1(MyState s)                { s.cb.put(0, 'a');                                 }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.cb.get(0);                               }
     }
 
-    public static class FloatViewTest implements Actor2_Test<FloatBuffer, LongResult1> {
-        @Override public FloatBuffer newState()                 { return order(ByteBuffer.allocateDirect(16)).asFloatBuffer();   }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                          }
-        @Override public void actor1(FloatBuffer b, LongResult1 r)   { b.put(0, -1F);                                     }
-        @Override public void actor2(FloatBuffer b, LongResult1 r)   { r.r1 = Float.floatToRawIntBits(b.get(0));          }
+    @ConcurrencyStressTest
+    public static class DoubleViewTest {
+        @Actor public void actor1(MyState s)                { s.db.put(0, -1D);                                 }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = Double.doubleToRawLongBits(s.db.get(0));   }
     }
 
-    public static class LongViewTest implements Actor2_Test<LongBuffer, LongResult1> {
-        @Override public LongBuffer newState()                  { return order(ByteBuffer.allocateDirect(16)).asLongBuffer();    }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                          }
-        @Override public void actor1(LongBuffer b, LongResult1 r)    { b.put(0, -1);                                      }
-        @Override public void actor2(LongBuffer b, LongResult1 r)    { r.r1 = b.get(0);                                   }
+    @ConcurrencyStressTest
+    public static class FloatViewTest {
+        @Actor public void actor1(MyState s)                { s.fb.put(0, -1F);                                 }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = Float.floatToRawIntBits(s.fb.get(0));      }
     }
 
-    public static class ShortViewTest implements Actor2_Test<ShortBuffer, LongResult1> {
-        @Override public ShortBuffer newState()                 { return order(ByteBuffer.allocateDirect(16)).asShortBuffer();   }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                               }
-        @Override public void actor1(ShortBuffer b, LongResult1 r)   { b.put(0, (short) -1);                             }
-        @Override public void actor2(ShortBuffer b, LongResult1 r)   { r.r1 = b.get(0);                                  }
+    @ConcurrencyStressTest
+    public static class LongViewTest {
+        @Actor public void actor1(MyState s)                { s.lb.put(0, -1);                                  }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.lb.get(0);                               }
+    }
+
+    @ConcurrencyStressTest
+    public static class ShortViewTest {
+        @Actor public void actor1(MyState s)                { s.sb.put(0, (short) -1);                          }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.sb.get(0);                               }
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/DoubleBufferAtomicityTests.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/DoubleBufferAtomicityTests.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,21 +24,30 @@
  */
 package org.openjdk.jcstress.tests.atomicity.buffers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult1;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
+import java.nio.CharBuffer;
 import java.nio.DoubleBuffer;
 
 public class DoubleBufferAtomicityTests {
 
-    public abstract static class DoubleBufferTest implements Actor2_Test<DoubleBuffer, LongResult1> {
-        @Override public DoubleBuffer newState()                     { return DoubleBuffer.allocate(16);                   }
-        @Override public LongResult1 newResult()                     { return new LongResult1();                           }
+    @State
+    public static class MyState {
+        private final DoubleBuffer b;
+
+        public MyState() {
+            b = DoubleBuffer.allocate(16);
+        }
     }
 
-    public static class DoubleTest extends DoubleBufferTest {
-        @Override public void actor1(DoubleBuffer b, LongResult1 r)  { b.put(0, -1D);                                      }
-        @Override public void actor2(DoubleBuffer b, LongResult1 r)  { r.r1 = Double.doubleToRawLongBits(b.get());         }
+    @ConcurrencyStressTest
+    public static class DoubleTest {
+        @Actor public void actor1(MyState s)                { s.b.put(0, -1D);                              }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = Double.doubleToRawLongBits(s.b.get()); }
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/FloatBufferAtomicityTests.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/FloatBufferAtomicityTests.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,21 +24,30 @@
  */
 package org.openjdk.jcstress.tests.atomicity.buffers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult1;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
+import java.nio.DoubleBuffer;
 import java.nio.FloatBuffer;
 
 public class FloatBufferAtomicityTests {
 
-    public abstract static class FloatBufferTest implements Actor2_Test<FloatBuffer, LongResult1> {
-        @Override public FloatBuffer newState()                { return FloatBuffer.allocate(16);                  }
-        @Override public LongResult1 newResult()               { return new LongResult1();                         }
+    @State
+    public static class MyState {
+        private final FloatBuffer b;
+
+        public MyState() {
+            b = FloatBuffer.allocate(16);
+        }
     }
 
-    public static class FloatTest extends FloatBufferTest {
-        @Override public void actor1(FloatBuffer b, LongResult1 r)  { b.put(0, -1F);                                    }
-        @Override public void actor2(FloatBuffer b, LongResult1 r)  { r.r1 = Float.floatToRawIntBits(b.get());          }
+    @ConcurrencyStressTest
+    public static class FloatTest {
+        @Actor public void actor1(MyState s)                { s.b.put(0, -1F);                                    }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = Float.floatToRawIntBits(s.b.get());          }
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/IntBufferAtomicityTests.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/IntBufferAtomicityTests.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,21 +24,30 @@
  */
 package org.openjdk.jcstress.tests.atomicity.buffers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult1;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
+import java.nio.FloatBuffer;
 import java.nio.IntBuffer;
 
 public class IntBufferAtomicityTests {
 
-    public abstract static class IntBufferTest implements Actor2_Test<IntBuffer, LongResult1> {
-        @Override public IntBuffer newState()                 { return IntBuffer.allocate(16);                     }
-        @Override public LongResult1 newResult()              { return new LongResult1();                          }
+    @State
+    public static class MyState {
+        private final IntBuffer b;
+
+        public MyState() {
+            b = IntBuffer.allocate(16);
+        }
     }
 
-    public static class IntTest extends IntBufferTest {
-        @Override public void actor1(IntBuffer b, LongResult1 r)   { b.put(0, -1);                                       }
-        @Override public void actor2(IntBuffer b, LongResult1 r)   { r.r1 = b.get();                                     }
+    @ConcurrencyStressTest
+    public static class IntTest {
+        @Actor public void actor1(MyState s)                { s.b.put(0, -1);                                       }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.b.get();                                     }
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/LongBufferAtomicityTests.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/LongBufferAtomicityTests.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,21 +24,28 @@
  */
 package org.openjdk.jcstress.tests.atomicity.buffers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult1;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
+import java.nio.IntBuffer;
 import java.nio.LongBuffer;
 
 public class LongBufferAtomicityTests {
 
-    public abstract static class LongBufferTest implements Actor2_Test<LongBuffer, LongResult1> {
-        @Override public LongBuffer newState()                { return LongBuffer.allocate(16);                  }
-        @Override public LongResult1 newResult()              { return new LongResult1();                        }
+    @State
+    public static class MyState {
+        private final LongBuffer b;
+
+        public MyState() {
+            b = LongBuffer.allocate(16);
+        }
     }
 
-    public static class LongTest extends LongBufferTest {
-        @Override public void actor1(LongBuffer b, LongResult1 r)  { b.put(0, -1L);                                   }
-        @Override public void actor2(LongBuffer b, LongResult1 r)  { r.r1 = b.get();                                  }
+    public static class LongTest {
+        @Actor public void actor1(MyState s)                 { s.b.put(0, -1L);                                   }
+        @Actor public void actor2(MyState s, LongResult1 r)  { r.r1 = s.b.get();                                  }
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/ShortBufferAtomicityTests.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/buffers/ShortBufferAtomicityTests.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,21 +24,30 @@
  */
 package org.openjdk.jcstress.tests.atomicity.buffers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.LongResult1;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
+import java.nio.LongBuffer;
 import java.nio.ShortBuffer;
 
 public class ShortBufferAtomicityTests {
 
-    public abstract static class ShortBufferTest implements Actor2_Test<ShortBuffer, LongResult1> {
-        @Override public ShortBuffer newState()                { return ShortBuffer.allocate(16);                  }
-        @Override public LongResult1 newResult()               { return new LongResult1();                         }
+    @State
+    public static class MyState {
+        private final ShortBuffer b;
+
+        public MyState() {
+            b = ShortBuffer.allocate(16);
+        }
     }
 
-    public static class ShortTest extends ShortBufferTest {
-        @Override public void actor1(ShortBuffer b, LongResult1 r)  { b.put(0, (short)-1);                              }
-        @Override public void actor2(ShortBuffer b, LongResult1 r)  { r.r1 = b.get();                                   }
+    @ConcurrencyStressTest
+    public static class ShortTest {
+        @Actor public void actor1(MyState s)                { s.b.put(0, (short)-1);                              }
+        @Actor public void actor2(MyState s, LongResult1 r) { r.r1 = s.b.get();                                   }
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/crosscache/ByteBufferIntAtomicityTest.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/crosscache/ByteBufferIntAtomicityTest.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,6 +24,9 @@
  */
 package org.openjdk.jcstress.tests.atomicity.crosscache;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.ByteResult4;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
@@ -31,54 +34,45 @@
 import java.nio.ByteOrder;
 import java.util.Random;
 
-public class ByteBufferIntAtomicityTest implements Actor2_Test<ByteBufferIntAtomicityTest.State, ByteResult4> {
+@ConcurrencyStressTest
+@State
+public class ByteBufferIntAtomicityTest {
 
-    @Override
-    public State newState() {
-        return new State();
+    /**
+     * We don't have the alignment information, so we would try to read/write to the
+     * random offset within the byte array.
+     */
+
+    /** Array size: 256 bytes inevitably crosses the cache line on most implementations */
+    public static final int SIZE = 256;
+
+    public static final Random RANDOM = new Random();
+    public static final int COMPONENT_SIZE = 4;
+
+    /** Alignment constraint: 4-bytes is default, for integers */
+    public static final int ALIGN = Integer.getInteger("align", COMPONENT_SIZE);
+
+    public final ByteBuffer bytes;
+    public final int offset;
+
+    public ByteBufferIntAtomicityTest() {
+        bytes = ByteBuffer.allocate(SIZE);
+        bytes.order(ByteOrder.nativeOrder());
+        offset = RANDOM.nextInt((SIZE - COMPONENT_SIZE)/ALIGN)*ALIGN;
     }
 
-    @Override
-    public void actor1(State s, ByteResult4 r) {
-        s.bytes.putInt(s.offset, 0xFFFFFFFF);
+    @Actor
+    public void actor1(ByteResult4 r) {
+        bytes.putInt(offset, 0xFFFFFFFF);
     }
 
-    @Override
-    public void actor2(State s, ByteResult4 r) {
-        int t = s.bytes.getInt(s.offset);
+    @Actor
+    public void actor2(ByteResult4 r) {
+        int t = bytes.getInt(offset);
         r.r1 = (byte) ((t >> 0) & 0xFF);
         r.r2 = (byte) ((t >> 8) & 0xFF);
         r.r3 = (byte) ((t >> 16) & 0xFF);
         r.r4 = (byte) ((t >> 24) & 0xFF);
     }
 
-    @Override
-    public ByteResult4 newResult() {
-        return new ByteResult4();
-    }
-
-    /**
-     * We don't have the alignment information, so we would try to read/write to the
-     * random offset within the byte array.
-     */
-    public static class State {
-        /** Array size: 256 bytes inevitably crosses the cache line on most implementations */
-        public static final int SIZE = 256;
-
-        public static final Random RANDOM = new Random();
-        public static final int COMPONENT_SIZE = 4;
-
-        /** Alignment constraint: 4-bytes is default, for integers */
-        public static final int ALIGN = Integer.getInteger("align", COMPONENT_SIZE);
-
-        public final ByteBuffer bytes;
-        public final int offset;
-
-        public State() {
-            bytes = ByteBuffer.allocate(SIZE);
-            bytes.order(ByteOrder.nativeOrder());
-            offset = RANDOM.nextInt((SIZE - COMPONENT_SIZE)/ALIGN)*ALIGN;
-        }
-    }
-
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/crosscache/DirectByteBufferIntAtomicityTest.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/crosscache/DirectByteBufferIntAtomicityTest.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,6 +24,9 @@
  */
 package org.openjdk.jcstress.tests.atomicity.crosscache;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.ByteResult4;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
@@ -31,54 +34,45 @@
 import java.nio.ByteOrder;
 import java.util.Random;
 
-public class DirectByteBufferIntAtomicityTest implements Actor2_Test<DirectByteBufferIntAtomicityTest.State, ByteResult4> {
+@ConcurrencyStressTest
+@State
+public class DirectByteBufferIntAtomicityTest {
 
-    @Override
-    public State newState() {
-        return new State();
+    /**
+     * We don't have the alignment information, so we would try to read/write to the
+     * random offset within the byte array.
+     */
+
+    /** Array size: 256 bytes inevitably crosses the cache line on most implementations */
+    public static final int SIZE = 256;
+
+    public static final Random RANDOM = new Random();
+    public static final int COMPONENT_SIZE = 4;
+
+    /** Alignment constraint: 4-bytes is default, for integers */
+    public static final int ALIGN = Integer.getInteger("align", COMPONENT_SIZE);
+
+    public final ByteBuffer bytes;
+    public final int offset;
+
+    public DirectByteBufferIntAtomicityTest() {
+        bytes = ByteBuffer.allocateDirect(SIZE);
+        bytes.order(ByteOrder.nativeOrder());
+        offset = RANDOM.nextInt((SIZE - COMPONENT_SIZE)/ALIGN)*ALIGN;
     }
 
-    @Override
-    public void actor1(State s, ByteResult4 r) {
-        s.bytes.putInt(s.offset, 0xFFFFFFFF);
+    @Actor
+    public void actor1() {
+        bytes.putInt(offset, 0xFFFFFFFF);
     }
 
-    @Override
-    public void actor2(State s, ByteResult4 r) {
-        int t = s.bytes.getInt(s.offset);
+    @Actor
+    public void actor2(ByteResult4 r) {
+        int t = bytes.getInt(offset);
         r.r1 = (byte) ((t >> 0) & 0xFF);
         r.r2 = (byte) ((t >> 8) & 0xFF);
         r.r3 = (byte) ((t >> 16) & 0xFF);
         r.r4 = (byte) ((t >> 24) & 0xFF);
     }
 
-    @Override
-    public ByteResult4 newResult() {
-        return new ByteResult4();
-    }
-
-    /**
-     * We don't have the alignment information, so we would try to read/write to the
-     * random offset within the byte array.
-     */
-    public static class State {
-        /** Array size: 256 bytes inevitably crosses the cache line on most implementations */
-        public static final int SIZE = 256;
-
-        public static final Random RANDOM = new Random();
-        public static final int COMPONENT_SIZE = 4;
-
-        /** Alignment constraint: 4-bytes is default, for integers */
-        public static final int ALIGN = Integer.getInteger("align", COMPONENT_SIZE);
-
-        public final ByteBuffer bytes;
-        public final int offset;
-
-        public State() {
-            bytes = ByteBuffer.allocateDirect(SIZE);
-            bytes.order(ByteOrder.nativeOrder());
-            offset = RANDOM.nextInt((SIZE - COMPONENT_SIZE)/ALIGN)*ALIGN;
-        }
-    }
-
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/crosscache/UnsafeIntAtomicityTest.java	Thu Mar 13 22:06:22 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/atomicity/crosscache/UnsafeIntAtomicityTest.java	Thu Mar 13 23:39:28 2014 +0400
@@ -24,62 +24,56 @@
  */
 package org.openjdk.jcstress.tests.atomicity.crosscache;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.ByteResult4;
 import org.openjdk.jcstress.tests.Actor2_Test;
 import org.openjdk.jcstress.util.UnsafeHolder;
 
 import java.util.Random;
 
-public class UnsafeIntAtomicityTest implements Actor2_Test<UnsafeIntAtomicityTest.State, ByteResult4> {
+@ConcurrencyStressTest
+@State
+public class UnsafeIntAtomicityTest {
 
-    @Override
-    public State newState() {
-        return new State();
+    /**
+     * We don't have the alignment information, so we would try to read/write to the
+     * random offset within the byte array.
+     */
+
+    /** Array size: 256 bytes inevitably crosses the cache line on most implementations */
+    public static final int SIZE = 256;
+
+    public static final Random RANDOM = new Random();
+    public static final int ARRAY_BASE_OFFSET = UnsafeHolder.U.arrayBaseOffset(byte[].class);
+    public static final int ARRAY_BASE_SCALE = UnsafeHolder.U.arrayIndexScale(byte[].class);
+    public static final int COMPONENT_SIZE = 4;
+
+    /** Alignment constraint: 4-bytes is default, for integers */
+    public static final int ALIGN = Integer.getInteger("align", COMPONENT_SIZE);
+
+    public final byte[] bytes;
+    public final long offset;
+
+    public UnsafeIntAtomicityTest() {
+        bytes = new byte[SIZE];
+        int index = RANDOM.nextInt((SIZE - COMPONENT_SIZE)/ALIGN)*ALIGN;
+        offset = ARRAY_BASE_OFFSET + ARRAY_BASE_SCALE*index;
     }
 
-    @Override
-    public void actor1(State s, ByteResult4 r) {
-        UnsafeHolder.U.putInt(s.bytes, s.offset, 0xFFFFFFFF);
+    @Actor
+    public void actor1() {
+        UnsafeHolder.U.putInt(bytes, offset, 0xFFFFFFFF);
     }
 
-    @Override
-    public void actor2(State s, ByteResult4 r) {
-        int t = UnsafeHolder.U.getInt(s.bytes, s.offset);
+    @Actor
+    public void actor2(ByteResult4 r) {
+        int t = UnsafeHolder.U.getInt(bytes, offset);
         r.r1 = (byte) ((t >> 0) & 0xFF);
         r.r2 = (byte) ((t >> 8) & 0xFF);
         r.r3 = (byte) ((t >> 16) & 0xFF);
         r.r4 = (byte) ((t >> 24) & 0xFF);
     }
 
-    @Override
-    public ByteResult4 newResult() {
-        return new ByteResult4();
-    }
-
-    /**
-     * We don't have the alignment information, so we would try to read/write to the
-     * random offset within the byte array.
-     */
-    public static class State {
-        /** Array size: 256 bytes inevitably crosses the cache line on most implementations */
-        public static final int SIZE = 256;
-
-        public static final Random RANDOM = new Random();
-        public static final int ARRAY_BASE_OFFSET = UnsafeHolder.U.arrayBaseOffset(byte[].class);
-        public static final int ARRAY_BASE_SCALE = UnsafeHolder.U.arrayIndexScale(byte[].class);
-        public static final int COMPONENT_SIZE = 4;
-
-        /** Alignment constraint: 4-bytes is default, for integers */
-        public static final int ALIGN = Integer.getInteger("align", COMPONENT_SIZE);
-
-        public final byte[] bytes;
-        public final long offset;
-
-        public State() {
-            bytes = new byte[SIZE];
-            int index = RANDOM.nextInt((SIZE - COMPONENT_SIZE)/ALIGN)*ALIGN;
-            offset = ARRAY_BASE_OFFSET + ARRAY_BASE_SCALE*index;
-        }
-    }
-
 }