Home | History | Annotate | Download | only in bytecode
      1 package org.robolectric.internal.bytecode;
      2 
      3 import static org.robolectric.internal.bytecode.MethodCallSite.Kind.STATIC;
      4 
      5 import java.lang.invoke.MethodHandle;
      6 import java.lang.invoke.MethodType;
      7 
      8 public class MethodCallSite extends RoboCallSite {
      9   private final String name;
     10   private final MethodHandle original;
     11   private final Kind kind;
     12 
     13   public MethodCallSite(MethodType type, Class<?> caller, String name, MethodHandle original,
     14       Kind kind) {
     15     super(type, caller);
     16     this.name = name;
     17     this.original = original;
     18     this.kind = kind;
     19   }
     20 
     21   public String getName() {
     22     return name;
     23   }
     24 
     25   public MethodHandle getOriginal() {
     26     return original;
     27   }
     28 
     29   public Class<?> thisType() {
     30     return isStatic() ? null : type().parameterType(0);
     31   }
     32 
     33   public boolean isStatic() {
     34     return kind == STATIC;
     35   }
     36 
     37   @Override public String toString() {
     38     return "RoboCallSite{" +
     39         "caller=" + getCaller() +
     40         ", original=" + original +
     41         ", kind=" + kind +
     42         '}';
     43   }
     44 
     45   public enum Kind {
     46     REGULAR,
     47     STATIC
     48   }
     49 }
     50