aboutsummaryrefslogtreecommitdiff
path: root/sandbox/src/main/java/org/robolectric/internal/bytecode/MethodCallSite.java
blob: df6f3f84716abe48c3954a1986aeff1fdd65481b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package org.robolectric.internal.bytecode;

import static org.robolectric.internal.bytecode.MethodCallSite.Kind.STATIC;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;

public class MethodCallSite extends RoboCallSite {
  private final String name;
  private final MethodHandle original;
  private final Kind kind;

  private final boolean isNative;

  public MethodCallSite(
      Class<?> theClass,
      MethodType type,
      String name,
      MethodHandle original,
      Kind kind,
      boolean isNative) {
    super(type, theClass);
    this.name = name;
    this.original = original;
    this.kind = kind;
    this.isNative = isNative;
  }

  public String getName() {
    return name;
  }

  public MethodHandle getOriginal() {
    return original;
  }

  public Class<?> thisType() {
    return isStatic() ? null : type().parameterType(0);
  }

  public boolean isStatic() {
    return kind == STATIC;
  }

  public boolean isNative() {
    return isNative;
  }

  @Override public String toString() {
    return "RoboCallSite{" +
        "theClass=" + getTheClass() +
        ", original=" + original +
        ", kind=" + kind +
        '}';
  }

  public enum Kind {
    REGULAR,
    STATIC
  }
}