blob: 7d8c17723edc97b6d362503f9d09df976bdf0d2f [file] [log] [blame]
Shih-wei Liao9407c602011-09-16 10:36:43 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3package com.example.StackWalk2;
4
5public class StackWalk2 {
6 // use v1 for this
7
8 String str = new String(); // use v0 for str in <init>
9
10 int f() {
11 g(1); // use v0 for 1, v1 for this
12 g(2); // use v0 for 2, v1 for this
13 strTest(); // use v1 for this
14 return 0;
15 }
16
17 void g(int num_calls) throws RuntimeException {
18 if (num_calls == 1) { // use v0 for 1, v3 for num_calls
19 System.logI("1st call"); // use v0 for PrintStream, v1 for "1st call"
20 refmap2(24); // use v0 for 24, v2 for this
21 } else if (num_calls == 2) { // use v0 for 2, v3 for num_calls
22 System.logI("2nd call"); // use v0 for PrintStream, v1 for "2nd call"
23 refmap2(25); // use v0 for 24, v2 for this
24 }
25 throw new RuntimeException(); // use v0 for new RuntimeException
26 }
27
28 void strTest() {
29 System.logI(str); // use v1 for PrintStream, v2, v3 for str
30 str = null; // use v1 for null, v3 for str
31 str = new String("ya"); // use v2 for "ya", v1 for new String
32 String s = str; // use v0, v1, v3
33 System.logI(str); // use v1 for PrintStream, v2, v3 for str
34 System.logI(s); // use v1 for PrintStream, v0 for s
35 s = null; // use v0
36 System.logI(s); // use v1 for PrintStream, v0 for s
37 }
38
39 native int refmap2(int x);
40
41 static {
42 System.loadLibrary("arttest");
43 }
44
45 public static void main(String[] args) {
46 StackWalk2 st = new StackWalk2();
47 st.f();
48 }
49}