changeset 393:97d6f5340387

Make common @Result generator.
author shade
date Mon, 27 Mar 2017 16:10:51 +0200
parents 9f21d933addf
children adba8ecf2dba
files jcstress-core/pom.xml jcstress-core/src/main/java/org/openjdk/jcstress/util/ResultUtils.java jcstress-result-gen/pom.xml jcstress-result-gen/src/main/java/org/openjdk/jcstress/ResultGenMain.java jcstress-result-gen/src/main/java/org/openjdk/jcstress/ResultGenerator.java jcstress-test-gen/src/main/java/org/openjdk/jcstress/TestGenMain.java jcstress-test-gen/src/main/java/org/openjdk/jcstress/generator/ResultGenerator.java jcstress-test-gen/src/main/java/org/openjdk/jcstress/generator/TestGenerator.java jcstress-test-gen/src/main/java/org/openjdk/jcstress/generator/seqcst/SeqCstTraceGenerator.java pom.xml
diffstat 10 files changed, 426 insertions(+), 180 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/pom.xml	Fri Mar 17 11:23:01 2017 +0100
+++ b/jcstress-core/pom.xml	Mon Mar 27 16:10:51 2017 +0200
@@ -69,6 +69,29 @@
                 <artifactId>buildnumber-maven-plugin</artifactId>
             </plugin>
             <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>gen</id>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <phase>
+                            generate-sources
+                        </phase>
+                        <configuration>
+                            <executable>${java.home}/bin/java</executable>
+                            <arguments>
+                                <argument>-jar</argument>
+                                <argument>../jcstress-result-gen/target/result-gen.jar</argument>
+                                <argument>${project.build.directory}/generated-sources/results/</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-jar-plugin</artifactId>
                 <executions>
@@ -100,6 +123,24 @@
                 </executions>
             </plugin>
             <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${project.build.directory}/generated-sources/results/</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-enforcer-plugin</artifactId>
             </plugin>
@@ -129,6 +170,12 @@
             <version>4.6</version>
         </dependency>
         <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>jcstress-result-gen</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <version>4.10</version>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/util/ResultUtils.java	Mon Mar 27 16:10:51 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jcstress.util;
+
+public class ResultUtils {
+
+    public static String resultName(Class<?>... args) {
+        String name = "";
+        for (Class k : args) {
+            if (k.isPrimitive()) {
+                if (k == boolean.class) name += "Z";
+                if (k == byte.class)    name += "B";
+                if (k == short.class)   name += "S";
+                if (k == char.class)    name += "C";
+                if (k == int.class)     name += "I";
+                if (k == long.class)    name += "J";
+                if (k == float.class)   name += "F";
+                if (k == double.class)  name += "D";
+            } else {
+                name += "L";
+            }
+        }
+        name += "_Result";
+        return name;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-result-gen/pom.xml	Mon Mar 27 16:10:51 2017 +0200
@@ -0,0 +1,84 @@
+<!--
+Copyright (c) 2017, Red Hat Inc. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 only, as
+published by the Free Software Foundation.  Oracle designates this
+particular file as subject to the "Classpath" exception as provided
+by Oracle in the LICENSE file that accompanied this code.
+
+This code is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+version 2 for more details (a copy is included in the LICENSE file that
+accompanied this code).
+
+You should have received a copy of the GNU General Public License version
+2 along with this work; if not, write to the Free Software Foundation,
+Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+or visit www.oracle.com if you need additional information or have any
+questions.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.openjdk.jcstress</groupId>
+        <artifactId>jcstress-parent</artifactId>
+        <version>0.3-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>jcstress-result-gen</artifactId>
+    <packaging>jar</packaging>
+
+    <name>JCStress Results Generator</name>
+    <url>http://maven.apache.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>com.mycila.maven-license-plugin</groupId>
+                <artifactId>maven-license-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>testgen</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <finalName>result-gen</finalName>
+                            <transformers>
+                                <transformer
+                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                                    <mainClass>org.openjdk.jcstress.ResultGenMain</mainClass>
+                                </transformer>
+                            </transformers>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-enforcer-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-result-gen/src/main/java/org/openjdk/jcstress/ResultGenMain.java	Mon Mar 27 16:10:51 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jcstress;
+
+import java.io.IOException;
+
+public class ResultGenMain {
+
+    public static final Class<?>[] CLASSES = new Class<?>[] {
+                boolean.class, byte.class, short.class, char.class,
+                int.class, long.class, float.class, double.class,
+                Object.class,
+    };
+
+    public static void main(String[] args) throws IOException {
+        if (args.length >= 1) {
+            ResultGenerator rg = new ResultGenerator(args[0]);
+
+            for (Class<?> c : CLASSES) {
+                rg.generateResult(c);
+                rg.generateResult(c, c);
+                rg.generateResult(c, c, c);
+                rg.generateResult(c, c, c, c);
+                rg.generateResult(c, c, c, c, c);
+                rg.generateResult(c, c, c, c, c, c);
+            }
+
+            for (Class<?> c1 : CLASSES) {
+                for (Class<?> c2 : CLASSES) {
+                    rg.generateResult(c1, c2);
+                }
+            }
+
+            for (Class<?> c1 : CLASSES) {
+                for (Class<?> c2 : CLASSES) {
+                    for (Class<?> c3 : CLASSES) {
+                        rg.generateResult(c1, c2, c3);
+                    }
+                }
+            }
+        } else {
+            throw new IllegalStateException("Please provide the destination dir");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-result-gen/src/main/java/org/openjdk/jcstress/ResultGenerator.java	Mon Mar 27 16:10:51 2017 +0200
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jcstress;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashSet;
+import java.util.Set;
+
+public class ResultGenerator {
+    private final Set<String> generatedResults = new HashSet<>();
+    private final String srcRoot;
+
+    public ResultGenerator(String srcRoot) {
+        this.srcRoot = srcRoot;
+    }
+
+    public String generateResult(Class<?>... args) {
+        String name = "";
+        for (Class k : args) {
+            if (k.isPrimitive()) {
+                if (k == boolean.class) name += "Z";
+                if (k == byte.class)    name += "B";
+                if (k == short.class)   name += "S";
+                if (k == char.class)    name += "C";
+                if (k == int.class)     name += "I";
+                if (k == long.class)    name += "J";
+                if (k == float.class)   name += "F";
+                if (k == double.class)  name += "D";
+            } else {
+                name += "L";
+            }
+        }
+        name += "_Result";
+
+        // already generated
+        if (!generatedResults.add(name))
+            return name;
+
+        PrintWriter pw;
+        try {
+            Path dir = Paths.get(srcRoot, "org.openjdk.jcstress.infra.results.".split("\\."));
+            Path file = dir.resolve(name + ".java");
+            Files.createDirectories(dir);
+            pw = new PrintWriter(file.toFile());
+        } catch (IOException e) {
+            throw new IllegalStateException(e);
+        }
+
+        pw.println("package org.openjdk.jcstress.infra.results;");
+        pw.println("");
+        pw.println("import java.io.Serializable;");
+        pw.println("import org.openjdk.jcstress.annotations.Result;");
+        pw.println("");
+        pw.println("@Result");
+        pw.println("public class " + name + " implements Serializable {");
+
+        {
+            int n = 1;
+            for (Class k : args) {
+                pw.println("    @sun.misc.Contended");
+                pw.println("    @jdk.internal.vm.annotation.Contended");
+                pw.println("    public " + k.getSimpleName() + " r" + n + ";");
+                pw.println();
+                n++;
+            }
+        }
+
+        pw.println("    public int hashCode() {");
+        pw.println("        int result = 0;");
+        {
+            int n = 1;
+            for (Class k : args) {
+                if (k == boolean.class) {
+                    pw.println("        result = 31*result + (r" + n + " ? 1 : 0);");
+                }
+                if (k == byte.class || k == short.class || k == char.class || k == int.class) {
+                    pw.println("        result = 31*result + r" + n + ";");
+                }
+                if (k == long.class) {
+                    pw.println("        result = 31*result + (int) (r" + n + " ^ (r" + n + " >>> 32));");
+                }
+                if (k == double.class) {
+                    pw.println("        result = 31*result + (int) (Double.doubleToLongBits(r" + n + ") ^ (Double.doubleToLongBits(r" + n + ") >>> 32));");
+                }
+                if (k == float.class) {
+                    pw.println("        result = 31*result + (int) (Float.floatToIntBits(r" + n + ") ^ (Float.floatToIntBits(r" + n + ") >>> 32));");
+                }
+                n++;
+            }
+        }
+        pw.println("        return result;");
+        pw.println("    }");
+        pw.println();
+        pw.println("    public boolean equals(Object o) {");
+        pw.println("        if (this == o) return true;");
+        pw.println("        if (o == null || getClass() != o.getClass()) return false;");
+        pw.println();
+        pw.println("        " + name + " that = (" + name + ") o;\n");
+
+        {
+            int n = 1;
+            for (Class k : args) {
+                if (k == boolean.class || k == byte.class || k == short.class || k == char.class
+                        || k == int.class || k == long.class) {
+                    pw.println("        if (r" + n + " != that.r" + n + ") return false;");
+                }
+                if (k == double.class) {
+                    pw.println("        if (Double.compare(r" + n + ", that.r" + n + ") != 0) return false;");
+                }
+                if (k == float.class) {
+                    pw.println("        if (Float.compare(r" + n + ", that.r" + n + ") != 0) return false;");
+                }
+                n++;
+            }
+        }
+
+        pw.println("        return true;");
+        pw.println("    }");
+
+        pw.println("    public String toString() {");
+        pw.print("        return \"\" + ");
+
+        {
+            int n = 1;
+            for (Class k : args) {
+                if (n != 1)
+                    pw.print(" + \", \" + ");
+                if (k == char.class) {
+                    pw.print("(r" + n + " + 0)");
+                } else {
+                    pw.print("r" + n);
+                }
+                n++;
+            }
+            pw.println(";");
+        }
+
+        pw.println("    }");
+
+        pw.println("}");
+        pw.close();
+
+        return name;
+    }
+}
--- a/jcstress-test-gen/src/main/java/org/openjdk/jcstress/TestGenMain.java	Fri Mar 17 11:23:01 2017 +0100
+++ b/jcstress-test-gen/src/main/java/org/openjdk/jcstress/TestGenMain.java	Mon Mar 27 16:10:51 2017 +0200
@@ -32,7 +32,7 @@
 
     public static void main(String[] args) throws IOException {
         if (args.length >= 2) {
-            new TestGenerator(args[0], args[1]).run();
+            new TestGenerator(args[0]).run();
         } else {
             throw new IllegalStateException("Please provide the destination dir");
         }
--- a/jcstress-test-gen/src/main/java/org/openjdk/jcstress/generator/ResultGenerator.java	Fri Mar 17 11:23:01 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.jcstress.generator;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashSet;
-import java.util.Set;
-
-public class ResultGenerator {
-    private final Set<String> generatedResults = new HashSet<>();
-    private final String srcRoot;
-
-    public ResultGenerator(String srcRoot) {
-        this.srcRoot = srcRoot;
-    }
-
-    public String generateResult(TestGenerator.Types types) {
-        String name = "";
-        for (Class k : types.all()) {
-            if (k == boolean.class) name += "X";
-            if (k == byte.class) name += "B";
-            if (k == short.class) name += "S";
-            if (k == char.class) name += "C";
-            if (k == int.class) name += "I";
-            if (k == long.class) name += "L";
-            if (k == float.class) name += "F";
-            if (k == double.class) name += "D";
-        }
-        name += "_Result";
-
-        // already generated
-        if (!generatedResults.add(name))
-            return name;
-
-        PrintWriter pw;
-        try {
-            Path dir = Paths.get(srcRoot, "org.openjdk.jcstress.infra.results.".split("\\."));
-            Path file = dir.resolve(name + ".java");
-            Files.createDirectories(dir);
-            pw = new PrintWriter(file.toFile());
-        } catch (IOException e) {
-            throw new IllegalStateException(e);
-        }
-
-        pw.println("package org.openjdk.jcstress.infra.results;");
-        pw.println("");
-        pw.println("import java.io.Serializable;");
-        pw.println("import org.openjdk.jcstress.annotations.Result;");
-        pw.println("");
-        pw.println("@Result");
-        pw.println("public class " + name + " implements Serializable {");
-
-        {
-            int n = 1;
-            for (Class k : types.all()) {
-                pw.println("    @sun.misc.Contended");
-                pw.println("    @jdk.internal.vm.annotation.Contended");
-                pw.println("    public " + k.getSimpleName() + " r" + n + ";");
-                pw.println();
-                n++;
-            }
-        }
-
-        pw.println("    public int hashCode() {");
-        pw.println("        int result = 0;");
-        {
-            int n = 1;
-            for (Class k : types.all()) {
-                if (k == boolean.class) {
-                    pw.println("        result = 31*result + (r" + n + " ? 1 : 0);");
-                }
-                if (k == byte.class || k == short.class || k == char.class || k == int.class) {
-                    pw.println("        result = 31*result + r" + n + ";");
-                }
-                if (k == long.class) {
-                    pw.println("        result = 31*result + (int) (r" + n + " ^ (r" + n + " >>> 32));");
-                }
-                if (k == double.class) {
-                    pw.println("        result = 31*result + (int) (Double.doubleToLongBits(r" + n + ") ^ (Double.doubleToLongBits(r" + n + ") >>> 32));");
-                }
-                if (k == float.class) {
-                    pw.println("        result = 31*result + (int) (Float.floatToIntBits(r" + n + ") ^ (Float.floatToIntBits(r" + n + ") >>> 32));");
-                }
-                n++;
-            }
-        }
-        pw.println("        return result;");
-        pw.println("    }");
-        pw.println();
-        pw.println("    public boolean equals(Object o) {");
-        pw.println("        if (this == o) return true;");
-        pw.println("        if (o == null || getClass() != o.getClass()) return false;");
-        pw.println();
-        pw.println("        " + name + " that = (" + name + ") o;\n");
-
-        {
-            int n = 1;
-            for (Class k : types.all()) {
-                if (k == boolean.class || k == byte.class || k == short.class || k == char.class
-                        || k == int.class || k == long.class) {
-                    pw.println("        if (r" + n + " != that.r" + n + ") return false;");
-                }
-                if (k == double.class) {
-                    pw.println("        if (Double.compare(r" + n + ", that.r" + n + ") != 0) return false;");
-                }
-                if (k == float.class) {
-                    pw.println("        if (Float.compare(r" + n + ", that.r" + n + ") != 0) return false;");
-                }
-                n++;
-            }
-        }
-
-        pw.println("        return true;");
-        pw.println("    }");
-
-        pw.println("    public String toString() {");
-        pw.print("        return \"\" + ");
-
-        {
-            int n = 1;
-            for (Class k : types.all()) {
-                if (n != 1)
-                    pw.print(" + \", \" + ");
-                if (k == char.class) {
-                    pw.print("(r" + n + " + 0)");
-                } else {
-                    pw.print("r" + n);
-                }
-                n++;
-            }
-            pw.println(";");
-        }
-
-        pw.println("    }");
-
-        pw.println("}");
-        pw.close();
-
-        return name;
-    }
-}
--- a/jcstress-test-gen/src/main/java/org/openjdk/jcstress/generator/TestGenerator.java	Fri Mar 17 11:23:01 2017 +0100
+++ b/jcstress-test-gen/src/main/java/org/openjdk/jcstress/generator/TestGenerator.java	Mon Mar 27 16:10:51 2017 +0200
@@ -24,6 +24,8 @@
  */
 package org.openjdk.jcstress.generator;
 
+import org.openjdk.jcstress.util.ResultUtils;
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.nio.file.Files;
@@ -41,14 +43,9 @@
 public class TestGenerator {
 
     private final String srcRoot;
-    private final String resRoot;
 
-    private final ResultGenerator resultGenerator;
-
-    public TestGenerator(String srcRoot, String resRoot) {
+    public TestGenerator(String srcRoot) {
         this.srcRoot = srcRoot;
-        this.resRoot = resRoot;
-        this.resultGenerator = new ResultGenerator(srcRoot);
     }
 
     public void run() throws IOException {
@@ -100,7 +97,7 @@
     }
 
    public void generate(Types types, Primitive prim, String klass, String pkg) throws IOException {
-        String resultName = resultGenerator.generateResult(types);
+        String resultName = ResultUtils.resultName(types.all());
 
         Path dir = Paths.get(srcRoot, pkg.split("\\."));
         Path file = dir.resolve(klass + ".java");
--- a/jcstress-test-gen/src/main/java/org/openjdk/jcstress/generator/seqcst/SeqCstTraceGenerator.java	Fri Mar 17 11:23:01 2017 +0100
+++ b/jcstress-test-gen/src/main/java/org/openjdk/jcstress/generator/seqcst/SeqCstTraceGenerator.java	Mon Mar 27 16:10:51 2017 +0200
@@ -24,8 +24,7 @@
  */
 package org.openjdk.jcstress.generator.seqcst;
 
-import org.openjdk.jcstress.generator.ResultGenerator;
-import org.openjdk.jcstress.generator.TestGenerator;
+import org.openjdk.jcstress.util.ResultUtils;
 
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -40,7 +39,6 @@
     private final String srcDir;
     private final String pkg;
     private final Target target;
-    private final ResultGenerator resultGenerator;
 
     public static void generate(String dst, String pkg, Target target) {
         new SeqCstTraceGenerator(dst, pkg, target).generate();
@@ -50,7 +48,6 @@
         this.srcDir = dst;
         this.pkg = pkg;
         this.target = target;
-        this.resultGenerator = new ResultGenerator(dst);
     }
 
     public void generate() {
@@ -177,7 +174,7 @@
             klasses[c] = int.class;
         }
 
-        String resultName = resultGenerator.generateResult(new TestGenerator.Types(klasses));
+        String resultName = ResultUtils.resultName(klasses);
 
         PrintWriter pw;
         try {
--- a/pom.xml	Fri Mar 17 11:23:01 2017 +0100
+++ b/pom.xml	Mon Mar 27 16:10:51 2017 +0200
@@ -243,6 +243,7 @@
 
     <modules>
         <module>jcstress-test-gen</module>
+        <module>jcstress-result-gen</module>
         <module>jcstress-core</module>
         <module>jcstress-samples</module>
         <module>jcstress-java-test-archetype</module>