changeset 261:d1ed559a1b55

Generators: check @Result and @State invariants better.
author shade
date Thu, 19 May 2016 20:15:09 +0300
parents c0db37918128
children ee48c25c08d8
files jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Thu May 19 15:43:53 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Thu May 19 20:15:09 2016 +0300
@@ -35,6 +35,7 @@
 import javax.annotation.processing.SupportedSourceVersion;
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.*;
+import javax.lang.model.type.TypeKind;
 import javax.lang.model.util.ElementFilter;
 import javax.tools.Diagnostic;
 import javax.tools.FileObject;
@@ -257,6 +258,31 @@
                     Result.class.getSimpleName() + " to work with", info.getTest());
         }
 
+        if (info.getState().getModifiers().contains(Modifier.FINAL)) {
+            throw new GenerationException("@" + State.class.getSimpleName() + " should not be final.",
+                    info.getState());
+        }
+
+        if (info.getResult().getModifiers().contains(Modifier.FINAL)) {
+            throw new GenerationException("@" + Result.class.getSimpleName() + " should not be final.",
+                    info.getResult());
+        }
+
+        if (!info.getState().getModifiers().contains(Modifier.PUBLIC)) {
+            throw new GenerationException("@" + State.class.getSimpleName() + " should be public.",
+                    info.getState());
+        }
+
+        if (!info.getResult().getModifiers().contains(Modifier.PUBLIC)) {
+            throw new GenerationException("@" + Result.class.getSimpleName() + " should be public.",
+                    info.getResult());
+        }
+
+        if (info.getResult().getSuperclass().toString().equals("java/lang/Object")) {
+            throw new GenerationException("@" + Result.class.getSimpleName() + " should not inherit other classes.",
+                    info.getResult());
+        }
+
         String className = getGeneratedName(info.getTest());
 
         PrintWriter pw;