summaryrefslogtreecommitdiff
path: root/test/StackWalk2/StackWalk2.java
blob: b4ea2d79e7cb88ca123dedd46995f2fa081ff654 (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
// Copyright 2011 Google Inc. All Rights Reserved.

public class StackWalk2 {
  // use v1 for this

  String str = new String();  // use v0 for str in <init>

  int f() {
    g(1);  // use v0 for 1, v1 for this
    g(2);  // use v0 for 2, v1 for this
    strTest();  // use v1 for this
    return 0;
  }

  void g(int num_calls) throws RuntimeException {
    if (num_calls == 1) {  // use v0 for 1, v3 for num_calls
      System.logI("1st call");  // use v0 for PrintStream, v1 for "1st call"
      refmap2(24);  // use v0 for 24, v2 for this
    } else if (num_calls == 2) {  // use v0 for 2, v3 for num_calls
      System.logI("2nd call");  // use v0 for PrintStream, v1 for "2nd call"
      refmap2(25);  // use v0 for 24, v2 for this
    }
    throw new RuntimeException();  // use v0 for new RuntimeException
  }

  void strTest() {
    System.logI(str);  // use v1 for PrintStream, v2, v3 for str
    str = null;  // use v1 for null, v3 for str
    str = new String("ya");  // use v2 for "ya", v1 for new String
    String s = str;  // use v0, v1, v3
    System.logI(str);  // use v1 for PrintStream, v2, v3 for str
    System.logI(s);  // use v1 for PrintStream, v0 for s
    s = null;  // use v0
    System.logI(s);  // use v1 for PrintStream, v0 for s
  }

  native int refmap2(int x);

  static {
    System.loadLibrary("arttest");
  }

  public static void main(String[] args) {
    StackWalk2 st = new StackWalk2();
    st.f();
  }
}