changeset 454:e9b52c98e4c5

Proper class lookup in ASMv4 generator.
author shade
date Sat, 01 Mar 2014 02:12:05 +0400
parents 20db85cbf265
children f3abe632b76f
files jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMGeneratorSource.java jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMMethodInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ClassInfoRepo.java
diffstat 3 files changed, 17 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMGeneratorSource.java	Sat Mar 01 01:43:09 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMGeneratorSource.java	Sat Mar 01 02:12:05 2014 +0400
@@ -25,7 +25,6 @@
 package org.openjdk.jmh.generators.bytecode;
 
 import org.objectweb.asm.ClassReader;
-import org.openjdk.jmh.generators.reflective.RFClassInfo;
 import org.openjdk.jmh.generators.source.ClassInfo;
 import org.openjdk.jmh.generators.source.GeneratorSource;
 import org.openjdk.jmh.generators.source.MetadataInfo;
@@ -85,11 +84,7 @@
 
     @Override
     public ClassInfo resolveClass(String className) {
-        try {
-            return new RFClassInfo(Class.forName(className));
-        } catch (ClassNotFoundException e) {
-            throw new IllegalStateException(e);
-        }
+        return classInfos.get(className);
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMMethodInfo.java	Sat Mar 01 01:43:09 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMMethodInfo.java	Sat Mar 01 02:12:05 2014 +0400
@@ -28,7 +28,6 @@
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
-import org.openjdk.jmh.generators.reflective.RFClassInfo;
 import org.openjdk.jmh.generators.source.ClassInfo;
 import org.openjdk.jmh.generators.source.MethodInfo;
 import org.openjdk.jmh.generators.source.ParameterInfo;
@@ -102,14 +101,7 @@
     public Collection<ParameterInfo> getParameters() {
         Collection<ParameterInfo> result = new ArrayList<ParameterInfo>();
         for (Type t : argumentTypes) {
-            ClassInfo ci = repo.get(t.getClassName().replaceAll("\\.", "/"));
-            if (ci == null) {
-                try {
-                    ci = new RFClassInfo(Class.forName(t.getClassName()));
-                } catch (ClassNotFoundException e) {
-                    throw new IllegalStateException("Unresolved class: " + this + " " + t, e);
-                }
-            }
+            ClassInfo ci = repo.get(t.getClassName());
             result.add(new ASMParameterInfo(ci));
         }
         return result;
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ClassInfoRepo.java	Sat Mar 01 01:43:09 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ClassInfoRepo.java	Sat Mar 01 02:12:05 2014 +0400
@@ -24,7 +24,7 @@
  */
 package org.openjdk.jmh.generators.bytecode;
 
-import org.objectweb.asm.Type;
+import org.openjdk.jmh.generators.reflective.RFClassInfo;
 import org.openjdk.jmh.generators.source.ClassInfo;
 
 import java.util.Collection;
@@ -33,16 +33,25 @@
 
 public class ClassInfoRepo {
 
-    private final Map<Type, ClassInfo> map = new HashMap<Type, ClassInfo>();
+    private final Map<String, ClassInfo> map = new HashMap<String, ClassInfo>();
 
     public ClassInfo get(String desc) {
-        Type type = Type.getType(desc);
-        return map.get(type);
+        desc = desc.replace('/', '.');
+        ClassInfo info = map.get(desc);
+        if (info != null) {
+            return info;
+        }
+
+        try {
+            return new RFClassInfo(Class.forName(desc));
+        } catch (ClassNotFoundException e) {
+            throw new IllegalStateException("Unable to resolve class: " + desc);
+        }
     }
 
     public void put(String desc, ClassInfo info) {
-        Type type = Type.getType(desc);
-        map.put(type, info);
+        desc = desc.replace('/', '.');
+        map.put(desc, info);
     }
 
     public Collection<ClassInfo> getInfos() {