-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathE_TestClass.java
More file actions
44 lines (35 loc) · 964 Bytes
/
E_TestClass.java
File metadata and controls
44 lines (35 loc) · 964 Bytes
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
package com.jvm;
import org.apache.commons.lang3.StringUtils;
//P187
public class E_TestClass {
private int m;
public int inc(){
return m + 1;
}
public int inc2(){
Integer x;
try {
x = 1;
return x; //将 1 放到slot中。执行return指令时,会读取slot,将slot中的值放到操作数栈顶
}catch (Exception e){
x = 2;
return x; //再次改变slot中的值
} finally{
x = 3; //改变x的值不影响返回值,以为返回值已经存储到slot中,未改变slot
}
}
public static void main(String[] args) throws Exception{
System.out.println(StringUtils.equals("", null));
//System.out.println(new E_TestClass().inc2());
}
}
class TestClass {
private int m;
public int incOut(){
int i = inc();
return i;
}
public int inc() {
return m + 1;
}
}