changeset 392:ffe2342401fb

Make other compilers happy: Fix some of fragile toString() uses.
author shade
date Wed, 12 Feb 2014 15:43:55 +0400
parents a90c0cf556f5
children 01f878b94d95
files jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/AnnUtils.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/CompilerControlProcessor.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/StateObjectHandler.java jmh-core/src/main/java/org/openjdk/jmh/runner/BaseMicroBenchmarkHandler.java
diffstat 5 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java	Wed Feb 12 14:20:52 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java	Wed Feb 12 15:43:55 2014 +0400
@@ -109,7 +109,7 @@
     public static List<String> getKnown() {
         List<String> res = new ArrayList<String>();
         for (Mode type : Mode.values()) {
-            res.add(type.toString() + "/" + type.shortLabel());
+            res.add(type.name() + "/" + type.shortLabel());
         }
         return res;
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/AnnUtils.java	Wed Feb 12 14:20:52 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/AnnUtils.java	Wed Feb 12 15:43:55 2014 +0400
@@ -26,6 +26,7 @@
 
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 import java.lang.annotation.Annotation;
 
@@ -58,7 +59,7 @@
         while (walk.getKind() != ElementKind.PACKAGE) {
             walk = walk.getEnclosingElement();
         }
-        return walk.toString();
+        return ((PackageElement)walk).getQualifiedName().toString();
     }
 
     /**
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/CompilerControlProcessor.java	Wed Feb 12 14:20:52 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/CompilerControlProcessor.java	Wed Feb 12 15:43:55 2014 +0400
@@ -30,6 +30,7 @@
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.annotation.processing.RoundEnvironment;
 import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
 import javax.tools.Diagnostic.Kind;
 import javax.tools.FileObject;
 import javax.tools.StandardLocation;
@@ -90,10 +91,10 @@
     private void addLine(ProcessingEnvironment processingEnv, Element element, CompilerControl.Mode command) {
         switch (element.getKind()) {
             case CLASS:
-                lines.add(command.command() + "," + element.toString().replaceAll("\\.", "/") + ".*");
+                lines.add(command.command() + "," + ((TypeElement)element).getQualifiedName().toString().replaceAll("\\.", "/") + ".*");
                 break;
             case METHOD:
-                lines.add(command.command() + "," + element.getEnclosingElement().toString().replaceAll("\\.", "/") + "." + element.getSimpleName().toString());
+                lines.add(command.command() + "," + ((TypeElement)element.getEnclosingElement()).getQualifiedName().toString().replaceAll("\\.", "/") + "." + element.getSimpleName().toString());
                 break;
             default:
                 processingEnv.getMessager().printMessage(Kind.ERROR,
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/StateObjectHandler.java	Wed Feb 12 14:20:52 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/StateObjectHandler.java	Wed Feb 12 15:43:55 2014 +0400
@@ -113,7 +113,7 @@
 
     private void bindState(ExecutableElement execMethod, TypeElement element, Scope scope, String implicitLabel) {
         Integer index;
-        String className = element.asType().toString();
+        String className = element.getQualifiedName().toString();
         switch (scope) {
             case Benchmark: {
                 index = globalIndexByType.get(className);
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseMicroBenchmarkHandler.java	Wed Feb 12 14:20:52 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseMicroBenchmarkHandler.java	Wed Feb 12 15:43:55 2014 +0400
@@ -94,7 +94,7 @@
         return list;
     }
 
-    private static final ExecutorType EXECUTOR_TYPE = Enum.valueOf(ExecutorType.class, System.getProperty("harness.executor", ExecutorType.FIXED_TPE.toString()));
+    private static final ExecutorType EXECUTOR_TYPE = Enum.valueOf(ExecutorType.class, System.getProperty("harness.executor", ExecutorType.FIXED_TPE.name()));
 
     private enum ExecutorType {