写了一个很简单的类,代码如下,接着就做简单的测试。
public class Die {
private int mCurrentPoint;
public Die() {
mCurrentPoint = getRandom();
}
public int roll() {
int p = getRandom();
setCurrentPoint(p);
return p;
}
public int getCurrentPoint() {
return this.mCurrentPoint;
}
private void setCurrentPoint(int p) {
this.mCurrentPoint = p;
}
private int getRandom() {
int r = (int) (Math.random() * 10) + 1;
if (r > 6) {
r -= 6;
}
return r;
}
public static void main(String args[]) {
Die d = new Die();
System.out.println(d.getCurrentPoint());
d.roll();
System.out.println(d.getCurrentPoint());
}
}
在Eclipse下,按F11,运行Main方法进行测试。按了大概六七次那样,突然报出来一个这样的错误。
6
2
FATAL ERROR in native method: JDWP on checking for an interface, jvmtiError=JVMTI_ERROR_WRONG_PHASE(112)
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATIONJDWP exit error JVMTI_ERROR_WRONG_PHASE(112): on checking for an interface [../../../src/share/back/util.c:1311]
用的是JDK1.7,没加其它运行参数。再看一下代码,好像也没什么问题啊。
于是继续测试,这一次,连续按F11十几次,也没发现再出现那个错误。又长见识了。。。