changeset 452:6a621d0090e7

Yak shaving: getEnclosing/getOwner -> getDeclared
author shade
date Sat, 01 Mar 2014 01:40:55 +0400
parents d1f2c90bd7f6
children 20db85cbf265
files jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APFieldInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APMethodInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMClassInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMFieldInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMMethodInfo.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/core/CompilerControlPlugin.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/HelperMethodValidationPlugin.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/ParamValidationPlugin.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/RFConstructorInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/RFFieldInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/RFMethodInfo.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 jmh-core/src/main/java/org/openjdk/jmh/generators/source/FieldInfo.java jmh-core/src/main/java/org/openjdk/jmh/generators/source/MethodInfo.java
diffstat 19 files changed, 53 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -117,7 +117,7 @@
     }
 
     @Override
-    public ClassInfo getEnclosingClass() {
+    public ClassInfo getDeclaringClass() {
         Element enclosingElement = el.getEnclosingElement();
         if (enclosingElement.getKind() == ElementKind.CLASS) {
             return new APClassInfo(processEnv, (TypeElement) enclosingElement);
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APFieldInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APFieldInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -68,7 +68,7 @@
     }
 
     @Override
-    public ClassInfo getOwner() {
+    public ClassInfo getDeclaringClass() {
         return new APClassInfo(processEnv, (TypeElement)ve.getEnclosingElement());
     }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APMethodInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/annotations/APMethodInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -48,7 +48,7 @@
     }
 
     @Override
-    public ClassInfo getOwner() {
+    public ClassInfo getDeclaringClass() {
         return ci;
     }
 
@@ -107,7 +107,7 @@
     }
 
     public String toString() {
-        return getOwner() + " " + getName() ;
+        return getDeclaringClass() + " " + getName() ;
     }
 
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMClassInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMClassInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -163,7 +163,7 @@
     }
 
     @Override
-    public ClassInfo getEnclosingClass() {
+    public ClassInfo getDeclaringClass() {
         if (declaringClass != null) {
             return classInfos.get(declaringClass);
         } else {
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMFieldInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMFieldInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -39,14 +39,14 @@
 public class ASMFieldInfo extends FieldVisitor implements FieldInfo {
 
     private final String type;
-    private final ASMClassInfo owner;
+    private final ASMClassInfo declaringClass;
     private final int access;
     private final String name;
     private final Map<String, AnnHandler> annotations;
 
-    public ASMFieldInfo(FieldVisitor fieldVisitor, ASMClassInfo owner, int access, String name, String desc, String signature) {
+    public ASMFieldInfo(FieldVisitor fieldVisitor, ASMClassInfo declaringClass, int access, String name, String desc, String signature) {
         super(Opcodes.ASM4, fieldVisitor);
-        this.owner = owner;
+        this.declaringClass = declaringClass;
         this.access = access;
         this.name = name;
         this.type = Type.getReturnType(desc).getClassName();
@@ -91,12 +91,12 @@
     }
 
     @Override
-    public ClassInfo getOwner() {
-        return owner;
+    public ClassInfo getDeclaringClass() {
+        return declaringClass;
     }
 
     @Override
     public String toString() {
-        return owner.getQualifiedName() + "." + name;
+        return declaringClass.getQualifiedName() + "." + name;
     }
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMMethodInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/bytecode/ASMMethodInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -42,7 +42,7 @@
 
 public class ASMMethodInfo extends MethodVisitor implements MethodInfo  {
 
-    private final ASMClassInfo classInfo;
+    private final ASMClassInfo declaringClass;
     private final Map<String, AnnHandler> annotations;
     private final int access;
     private final String name;
@@ -50,9 +50,9 @@
     private final Type[] argumentTypes;
     private final ClassInfoRepo repo;
 
-    public ASMMethodInfo(MethodVisitor methodVisitor, ClassInfoRepo repo, ASMClassInfo classInfo, int access, String name, String desc, String signature) {
+    public ASMMethodInfo(MethodVisitor methodVisitor, ClassInfoRepo repo, ASMClassInfo declaringClass, int access, String name, String desc, String signature) {
         super(Opcodes.ASM4, methodVisitor);
-        this.classInfo = classInfo;
+        this.declaringClass = declaringClass;
         this.repo = repo;
         this.access = access;
         this.name = name;
@@ -79,8 +79,8 @@
     }
 
     @Override
-    public ClassInfo getOwner() {
-        return classInfo;
+    public ClassInfo getDeclaringClass() {
+        return declaringClass;
     }
 
     @Override
@@ -90,7 +90,7 @@
 
     @Override
     public String getQualifiedName() {
-        return classInfo.getQualifiedName() + "." + name;
+        return declaringClass.getQualifiedName() + "." + name;
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Sat Mar 01 01:40:55 2014 +0400
@@ -323,7 +323,7 @@
                         }
                     }
 
-                    State stateAnn = BenchmarkGeneratorUtils.getAnnSuper(meth.getOwner(), State.class);
+                    State stateAnn = BenchmarkGeneratorUtils.getAnnSuper(meth.getDeclaringClass(), State.class);
                     if (stateAnn != null && stateAnn.value() == Scope.Group) {
                         throw new GenerationException(
                                 "Only @" + Group.class.getSimpleName() + " methods can implicitly reference @" + State.class.getSimpleName()
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java	Sat Mar 01 01:40:55 2014 +0400
@@ -29,8 +29,6 @@
 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;
@@ -106,7 +104,7 @@
         if (ann != null) {
             return ann;
         } else {
-            ClassInfo eci = ci.getEnclosingClass();
+            ClassInfo eci = ci.getDeclaringClass();
             if (eci != null) {
                 return getAnnSyntax(eci, annClass);
             }
@@ -119,7 +117,7 @@
         if (ann != null) {
             return ann;
         } else {
-            return getAnnSyntax(mi.getOwner(), annClass);
+            return getAnnSyntax(mi.getDeclaringClass(), annClass);
         }
     }
 
@@ -127,7 +125,7 @@
         String name = "";
         do {
             name = ci.getName() + (name.isEmpty() ? "" : "_" + name);
-        } while ((ci = ci.getEnclosingClass()) != null);
+        } while ((ci = ci.getDeclaringClass()) != null);
         return name;
     }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java	Sat Mar 01 01:40:55 2014 +0400
@@ -116,7 +116,7 @@
     }
 
     private static String getName(MethodInfo mi) {
-       return mi.getOwner().getQualifiedName().replaceAll("\\.", "/") + "." + mi.getName();
+       return mi.getDeclaringClass().getQualifiedName().replaceAll("\\.", "/") + "." + mi.getName();
     }
 
     private static String getName(ClassInfo ci) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/HelperMethodValidationPlugin.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/HelperMethodValidationPlugin.java	Sat Mar 01 01:40:55 2014 +0400
@@ -37,10 +37,10 @@
         try {
             for (MethodInfo element : BenchmarkGeneratorUtils.getMethodsAnnotatedWith(source, Setup.class)) {
                 // OK to have these annotation for @State objects
-                if (BenchmarkGeneratorUtils.getAnnSuper(element.getOwner(), State.class) != null) continue;
+                if (BenchmarkGeneratorUtils.getAnnSuper(element.getDeclaringClass(), State.class) != null) continue;
 
                 // Abstract classes are not instantiated, assume OK
-                if (element.getOwner().isAbstract()) continue;
+                if (element.getDeclaringClass().isAbstract()) continue;
 
                 source.printError(
                         "@" + Setup.class.getSimpleName() + " annotation is placed within " +
@@ -51,10 +51,10 @@
 
             for (MethodInfo element : BenchmarkGeneratorUtils.getMethodsAnnotatedWith(source, TearDown.class)) {
                 // OK to have these annotation for @State objects
-                if (BenchmarkGeneratorUtils.getAnnSuper(element.getOwner(), State.class) != null) continue;
+                if (BenchmarkGeneratorUtils.getAnnSuper(element.getDeclaringClass(), State.class) != null) continue;
 
                 // Abstract classes are not instantiated, assume OK
-                if (element.getOwner().isAbstract()) continue;
+                if (element.getDeclaringClass().isAbstract()) continue;
 
                 source.printError(
                             "@" + TearDown.class.getSimpleName() + " annotation is placed within " +
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/ParamValidationPlugin.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/ParamValidationPlugin.java	Sat Mar 01 01:40:55 2014 +0400
@@ -42,7 +42,7 @@
                     );
                 }
 
-                if (BenchmarkGeneratorUtils.getAnnSyntax(element.getOwner(), State.class) == null) {
+                if (BenchmarkGeneratorUtils.getAnnSyntax(element.getDeclaringClass(), State.class) == null) {
                     source.printError(
                             "@" + Param.class.getSimpleName() + " annotation should be placed in @" + State.class.getSimpleName() +
                                     "-annotated class.",
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java	Sat Mar 01 01:40:55 2014 +0400
@@ -393,7 +393,7 @@
                 result.add("            Field f;");
             }
             for (String paramName : so.getParamsLabels()) {
-                result.add("            f = " + so.getParam(paramName).getOwner().getQualifiedName() + ".class.getDeclaredField(\"" + paramName + "\");");
+                result.add("            f = " + so.getParam(paramName).getDeclaringClass().getQualifiedName() + ".class.getDeclaredField(\"" + paramName + "\");");
                 result.add("            f.setAccessible(true);");
                 result.add("            f.set(" + so.fieldIdentifier + ", " + so.getParamAccessor(paramName) + ");");
             }
@@ -421,7 +421,7 @@
                 result.add("            Field f;");
             }
             for (String paramName : so.getParamsLabels()) {
-                result.add("        f = " + so.getParam(paramName).getOwner().getQualifiedName() + ".class.getDeclaredField(\"" + paramName + "\");");
+                result.add("        f = " + so.getParam(paramName).getDeclaringClass().getQualifiedName() + ".class.getDeclaredField(\"" + paramName + "\");");
                 result.add("        f.setAccessible(true);");
                 result.add("        f.set(val, " + so.getParamAccessor(paramName) + ");");
             }
@@ -455,7 +455,7 @@
                 result.add("            Field f;");
             }
             for (String paramName : so.getParamsLabels()) {
-                result.add("            f = " + so.getParam(paramName).getOwner().getQualifiedName() + ".class.getDeclaredField(\"" + paramName + "\");");
+                result.add("            f = " + so.getParam(paramName).getDeclaringClass().getQualifiedName() + ".class.getDeclaredField(\"" + paramName + "\");");
                 result.add("            f.setAccessible(true);");
                 result.add("            f.setAccessible(true);");
                 result.add("            f.set(local, " + so.getParamAccessor(paramName) + ");");
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/RFConstructorInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/RFConstructorInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -36,17 +36,17 @@
 
 public class RFConstructorInfo implements MethodInfo {
 
-    private final ReflectiveClassInfo owner;
+    private final ReflectiveClassInfo declaringClass;
     private final Constructor m;
 
-    public RFConstructorInfo(ReflectiveClassInfo owner, Constructor m) {
-        this.owner = owner;
+    public RFConstructorInfo(ReflectiveClassInfo declaringClass, Constructor m) {
+        this.declaringClass = declaringClass;
         this.m = m;
     }
 
     @Override
-    public ClassInfo getOwner() {
-        return owner;
+    public ClassInfo getDeclaringClass() {
+        return declaringClass;
     }
 
     @Override
@@ -56,7 +56,7 @@
 
     @Override
     public String getQualifiedName() {
-        return owner.getQualifiedName() + "." + m.getName();
+        return declaringClass.getQualifiedName() + "." + m.getName();
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/RFFieldInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/RFFieldInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -32,17 +32,17 @@
 import java.lang.reflect.Modifier;
 
 public class RFFieldInfo implements FieldInfo {
-    private final ClassInfo owner;
+    private final ClassInfo declaringClass;
     private final Field f;
 
-    public RFFieldInfo(ClassInfo owner, Field f) {
-        this.owner = owner;
+    public RFFieldInfo(ClassInfo declaringClass, Field f) {
+        this.declaringClass = declaringClass;
         this.f = f;
     }
 
     @Override
-    public ClassInfo getOwner() {
-        return owner;
+    public ClassInfo getDeclaringClass() {
+        return declaringClass;
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/RFMethodInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/RFMethodInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -36,17 +36,17 @@
 
 public class RFMethodInfo implements MethodInfo {
 
-    private final ReflectiveClassInfo owner;
+    private final ReflectiveClassInfo declaringClass;
     private final Method m;
 
-    public RFMethodInfo(ReflectiveClassInfo owner, Method m) {
-        this.owner = owner;
+    public RFMethodInfo(ReflectiveClassInfo declaringClass, Method m) {
+        this.declaringClass = declaringClass;
         this.m = m;
     }
 
     @Override
-    public ClassInfo getOwner() {
-        return owner;
+    public ClassInfo getDeclaringClass() {
+        return declaringClass;
     }
 
     @Override
@@ -56,7 +56,7 @@
 
     @Override
     public String getQualifiedName() {
-        return owner.getQualifiedName() + "." + m.getName();
+        return declaringClass.getQualifiedName() + "." + m.getName();
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/ReflectiveClassInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/reflective/ReflectiveClassInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -109,7 +109,7 @@
     }
 
     @Override
-    public ClassInfo getEnclosingClass() {
+    public ClassInfo getDeclaringClass() {
         if (klass.getDeclaringClass() != null) {
             return new ReflectiveClassInfo(klass.getDeclaringClass());
         } else {
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/source/ClassInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/source/ClassInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -40,7 +40,7 @@
 
     ClassInfo getSuperClass();
 
-    ClassInfo getEnclosingClass();
+    ClassInfo getDeclaringClass();
 
     Collection<FieldInfo> getFields();
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/source/FieldInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/source/FieldInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -28,12 +28,12 @@
 
 public interface FieldInfo extends MetadataInfo {
 
-    ClassInfo getOwner();
-
     String getName();
 
     String getType();
 
+    ClassInfo getDeclaringClass();
+
     <T extends Annotation> T getAnnotation(Class<T> annClass);
 
     boolean isPublic();
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/source/MethodInfo.java	Sat Mar 01 01:28:16 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/source/MethodInfo.java	Sat Mar 01 01:40:55 2014 +0400
@@ -29,12 +29,12 @@
 
 public interface MethodInfo extends Comparable<MethodInfo>, MetadataInfo {
 
-    ClassInfo getOwner();
-
     String getName();
     String getQualifiedName();
     String getReturnType();
 
+    ClassInfo getDeclaringClass();
+
     Collection<ParameterInfo> getParameters();
 
     <T extends Annotation> T getAnnotation(Class<T> annClass);