changeset 263:6d24b407239a

Aggressive @Group validation: Prohibit using @State(Scope.Group) states by non-@Group methods.
author shade
date Thu, 21 Nov 2013 18:03:46 +0400
parents 710ac6afebd1
children c0362903bdbe
files jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelInvocationBench.java jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelIterationBench.java jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelTrialBench.java jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/MultipleGroupStateTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/exceptions/GroupBenchExceptionSignaturesTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/exceptions/GroupStateExceptionSignaturesTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchSetupTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTearDownTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateSetupTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateTearDownTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchSetupTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchTearDownTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateSetupTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateTearDownTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchSetupTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchTearDownTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateSetupTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateTearDownTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupBenchOrderTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupStateOrderTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchSetupOrderTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchTearDownOrderTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateSetupOrderTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateTearDownOrderTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateInvocationTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateIterationTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateRunTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupBenchSameThreadTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupStateSameThreadTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupBenchHelperTimesTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupStateHelperTimesTest.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java
diffstat 35 files changed, 157 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelInvocationBench.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelInvocationBench.java	Thu Nov 21 18:03:46 2013 +0400
@@ -26,6 +26,7 @@
 
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -123,12 +124,15 @@
     public void benchmark_teardown(BenchmarkTeardown g) {}
 
     @GenerateMicroBenchmark
+    @Group("T1")
     public void group_setup_teardown(GroupSetupTeardown g) {}
 
     @GenerateMicroBenchmark
+    @Group("T2")
     public void group_setup(GroupSetup g) {}
 
     @GenerateMicroBenchmark
+    @Group("T3")
     public void group_teardown(GroupTeardown g) {}
 
     @GenerateMicroBenchmark
--- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelIterationBench.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelIterationBench.java	Thu Nov 21 18:03:46 2013 +0400
@@ -26,6 +26,7 @@
 
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -123,12 +124,15 @@
     public void benchmark_teardown(BenchmarkTeardown g) {}
 
     @GenerateMicroBenchmark
+    @Group("T1")
     public void group_setup_teardown(GroupSetupTeardown g) {}
 
     @GenerateMicroBenchmark
+    @Group("T2")
     public void group_setup(GroupSetup g) {}
 
     @GenerateMicroBenchmark
+    @Group("T3")
     public void group_teardown(GroupTeardown g) {}
 
     @GenerateMicroBenchmark
--- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelTrialBench.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelTrialBench.java	Thu Nov 21 18:03:46 2013 +0400
@@ -26,6 +26,7 @@
 
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -123,12 +124,15 @@
     public void benchmark_teardown(BenchmarkTeardown g) {}
 
     @GenerateMicroBenchmark
+    @Group("T1")
     public void group_setup_teardown(GroupSetupTeardown g) {}
 
     @GenerateMicroBenchmark
+    @Group("T2")
     public void group_setup(GroupSetup g) {}
 
     @GenerateMicroBenchmark
+    @Group("T3")
     public void group_teardown(GroupTeardown g) {}
 
     @GenerateMicroBenchmark
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/MultipleGroupStateTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/MultipleGroupStateTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -26,6 +26,8 @@
 
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
 import org.openjdk.jmh.annotations.State;
@@ -43,16 +45,19 @@
     public static class G3 {}
 
     @GenerateMicroBenchmark
+    @Group("T")
     public void test1(G1 g1) {
 
     }
 
     @GenerateMicroBenchmark
+    @Group("T")
     public void test2(G1 g1, G2 g2) {
 
     }
 
     @GenerateMicroBenchmark
+    @Group("T")
     public void test3(G1 g1, G2 g2, G3 g3) {
 
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/exceptions/GroupBenchExceptionSignaturesTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/exceptions/GroupBenchExceptionSignaturesTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -26,6 +26,7 @@
 
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -56,6 +57,7 @@
     public void tearDown3() throws Exception {}
 
     @GenerateMicroBenchmark
+    @Group("T")
     public void test() throws Exception {}
 
 }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/exceptions/GroupStateExceptionSignaturesTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/exceptions/GroupStateExceptionSignaturesTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -26,6 +26,7 @@
 
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -65,6 +66,7 @@
     }
 
     @GenerateMicroBenchmark
+    @Group("T")
     public void test(MyState s) throws Exception {
     }
 
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchSetupTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchSetupTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -62,7 +64,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test() {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTearDownTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTearDownTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -62,7 +64,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test() {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -56,7 +58,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void doTest() {
         Assert.fail();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateSetupTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateSetupTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -64,7 +66,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateTearDownTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateTearDownTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -64,7 +66,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchSetupTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchSetupTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -56,7 +58,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test() {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchTearDownTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchTearDownTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -56,7 +58,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test() {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateSetupTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateSetupTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -58,7 +60,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateTearDownTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateTearDownTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Scope;
@@ -58,7 +60,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchSetupTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchSetupTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Threads;
@@ -53,7 +55,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test() {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchTearDownTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchTearDownTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Threads;
@@ -53,7 +55,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test() {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateSetupTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateSetupTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Threads;
@@ -55,7 +57,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateTearDownTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateTearDownTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Threads;
@@ -55,7 +57,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 1)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupBenchOrderTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupBenchOrderTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,7 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -108,7 +109,7 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
-    @Threads(1)
+    @Group("T")
     public void test() {
         tickRun = TICKER.incrementAndGet();
         Fixtures.work();
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupStateOrderTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupStateOrderTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,7 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -110,7 +111,7 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
-    @Threads(1)
+    @Group("T")
     public void test(MyState state) {
         state.tickRun = TICKER.incrementAndGet();
         Fixtures.work();
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchSetupOrderTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchSetupOrderTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -141,7 +143,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
-    @Threads(2)
+    @Group("T")
+    @GroupThreads(2)
     public void test() {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchTearDownOrderTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchTearDownOrderTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -140,7 +142,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
-    @Threads(2)
+    @Group("T")
+    @GroupThreads(2)
     public void test() {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateSetupOrderTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateSetupOrderTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -144,6 +146,7 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
+    @Group("T")
     public void test(MyState state) {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateTearDownOrderTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateTearDownOrderTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,7 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -143,6 +144,7 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
+    @Group("T")
     public void test(MyState state) {
         Fixtures.work();
     }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateInvocationTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateInvocationTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -29,6 +29,8 @@
 import org.openjdk.jmh.Main;
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -75,7 +77,8 @@
     @BenchmarkMode(Mode.All)
     @Warmup(iterations = 0)
     @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
        // Useless to test this condition here, intrinsic races.
 //        Assert.assertEquals("Run", 1, state.value);
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateIterationTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateIterationTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -29,6 +29,8 @@
 import org.openjdk.jmh.Main;
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -75,7 +77,8 @@
     @BenchmarkMode(Mode.All)
     @Warmup(iterations = 0)
     @Measurement(iterations = 50, time = 10, timeUnit = TimeUnit.MILLISECONDS)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
         Assert.assertEquals("Run", 1, state.value);
         Fixtures.work();
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateRunTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateRunTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -29,6 +29,8 @@
 import org.openjdk.jmh.Main;
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -75,7 +77,8 @@
     @BenchmarkMode(Mode.All)
     @Warmup(iterations = 0)
     @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
         Assert.assertEquals("Run", 1, state.value);
         Fixtures.work();
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,7 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
@@ -67,6 +68,7 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
+    @Group("T")
     @GroupThreads(2)
     public void test() {
         Fixtures.work();
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,7 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
@@ -69,6 +70,7 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
+    @Group("T")
     @GroupThreads(2)
     public void test(MyState s) {
         Fixtures.work();
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupBenchSameThreadTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupBenchSameThreadTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -112,7 +114,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test() {
         testInvocationThread.add(Thread.currentThread());
         Fixtures.work();
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupStateSameThreadTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupStateSameThreadTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,8 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.Mode;
@@ -116,7 +118,8 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
-    @Threads(4)
+    @Group("T")
+    @GroupThreads(4)
     public void test(MyState state) {
         state.testInvocationThread.add(Thread.currentThread());
         Fixtures.work();
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupBenchHelperTimesTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupBenchHelperTimesTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,7 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
@@ -154,6 +155,7 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
+    @Group("T")
     @GroupThreads(2)
     public void test() {
         Fixtures.work();
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupStateHelperTimesTest.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupStateHelperTimesTest.java	Thu Nov 21 18:03:46 2013 +0400
@@ -30,6 +30,7 @@
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
 import org.openjdk.jmh.annotations.GroupThreads;
 import org.openjdk.jmh.annotations.Level;
 import org.openjdk.jmh.annotations.Measurement;
@@ -158,6 +159,7 @@
     @Warmup(iterations = 0)
     @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Fork(1)
+    @Group("T")
     @GroupThreads(2)
     public void test(MyState state) {
         Fixtures.work();
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Thu Nov 21 17:02:45 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Thu Nov 21 18:03:46 2013 +0400
@@ -239,6 +239,45 @@
             }
         }
 
+        // check the @Group preconditions,
+        // ban some of the surprising configurations
+        //
+        for (MethodGroup group : result.values()) {
+            if (group.methods().size() == 1) {
+                ExecutableElement meth = (ExecutableElement) group.methods().iterator().next();
+                if (meth.getAnnotation(Group.class) == null) {
+                    for (VariableElement param : meth.getParameters()) {
+                        TypeElement stateType = (TypeElement) processingEnv.getTypeUtils().asElement(param.asType());
+                        State stateAnn = stateType.getAnnotation(State.class);
+                        if (stateAnn != null && stateAnn.value() == Scope.Group) {
+                            throw new GenerationException(
+                                    "Only @" + Group.class.getSimpleName() + " methods can reference @" + State.class.getSimpleName()
+                                            + "(" + Scope.class.getSimpleName() + "." + Scope.Group + ") states.",
+                                    meth);
+                        }
+                    }
+
+                    State stateAnn = meth.getEnclosingElement().getAnnotation(State.class);
+                    if (stateAnn != null && stateAnn.value() == Scope.Group) {
+                        throw new GenerationException(
+                                "Only @" + Group.class.getSimpleName() + " methods can implicitly reference @" + State.class.getSimpleName()
+                                        + "(" + Scope.class.getSimpleName() + "." + Scope.Group + ") states.",
+                                meth);
+                    }
+                }
+            } else {
+                for (Element m : group.methods()) {
+                    if (m.getAnnotation(Group.class) == null) {
+                        throw new GenerationException(
+                                "Internal error: multiple methods per @" + Group.class.getSimpleName()
+                                        + ", but not all methods have @" + Group.class.getSimpleName(),
+                                m);
+                    }
+                }
+            }
+
+        }
+
         String sourcePackage = packageName(clazz);
         if (sourcePackage.isEmpty()) {
             throw new GenerationException("Microbenchmark should have package other than default (" + clazz + ")", clazz);