changeset 445:ebbe41586e3e

Yak shaving: getNestedName() -> getName(), make proper nested name generators.
author shade
date Fri, 28 Feb 2014 17:04:38 +0400
parents 94062407bac0
children 2ebe23110222
files jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMClassInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/ReflectiveClassInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/source/ClassInfo.java
diffstat 6 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java	Fri Feb 28 16:55:02 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java	Fri Feb 28 17:04:38 2014 +0400
@@ -68,14 +68,8 @@
     }
 
     @Override
-    public String getNestedName() {
-        String name = "";
-        Element walk = el;
-        while (walk.getKind() != ElementKind.PACKAGE) {
-            name = walk.getSimpleName().toString() + (name.isEmpty() ? "" : "_" + name);
-            walk = walk.getEnclosingElement();
-        }
-        return name.substring(0, name.length());
+    public String getName() {
+        return el.getSimpleName().toString();
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMClassInfo.java	Fri Feb 28 16:55:02 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMClassInfo.java	Fri Feb 28 17:04:38 2014 +0400
@@ -126,7 +126,7 @@
     }
 
     @Override
-    public String getNestedName() {
+    public String getName() {
         return name;
     }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Fri Feb 28 16:55:02 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Fri Feb 28 17:04:38 2014 +0400
@@ -406,7 +406,7 @@
 
         String sourcePackage = clazz.getPackageName();
         String generatedPackageName = sourcePackage + ".generated";
-        String generatedClassName = clazz.getNestedName();
+        String generatedClassName = BenchmarkGeneratorUtils.getGeneratedName(clazz);
 
         BenchmarkInfo info = new BenchmarkInfo(clazz.getQualifiedName(), generatedPackageName, generatedClassName, result);
         validateBenchmarkInfo(info);
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java	Fri Feb 28 16:55:02 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java	Fri Feb 28 17:04:38 2014 +0400
@@ -29,6 +29,8 @@
 import org.openjdk.jmh.generators.source.GeneratorSource;
 import org.openjdk.jmh.generators.source.MethodInfo;
 
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
 import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -121,4 +123,12 @@
         }
     }
 
+    public static String getGeneratedName(ClassInfo ci) {
+        String name = "";
+        do {
+            name = ci.getName() + (name.isEmpty() ? "" : "_" + name);
+        } while ((ci = ci.getEnclosingClass()) != null);
+        return name;
+    }
+
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/ReflectiveClassInfo.java	Fri Feb 28 16:55:02 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/ReflectiveClassInfo.java	Fri Feb 28 17:04:38 2014 +0400
@@ -48,9 +48,8 @@
     }
 
     @Override
-    public String getNestedName() {
-        // FIXME
-        return getQualifiedName();
+    public String getName() {
+        return klass.getName();
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/source/ClassInfo.java	Fri Feb 28 16:55:02 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/source/ClassInfo.java	Fri Feb 28 17:04:38 2014 +0400
@@ -36,7 +36,7 @@
 
     String getQualifiedName();
 
-    String getNestedName();
+    String getName();
 
     ClassInfo getSuperClass();