Eclipse调试器是跳跃到错误return语句 [英] Eclipse debugger is jumping to the wrong return statement

查看:127
本文介绍了Eclipse调试器是跳跃到错误return语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到一个非常奇怪的情况。我在Android 2.1平台上做Java中的以下(通过Eclipse的伽利略):

I've run into a really weird situation. I'm doing the following in Java (through Eclipse Galileo) on the Android 2.1 platform:

// Get gravity & geomagnetic data to return to the caller.
final int SIZE_GRAVITY = 3, SIZE_GEOMAGNETIC = 3;
final float[] NOT_USED = null;
float[] outGravity = new float[SIZE_GRAVITY];
float[] outGeomagnetic = new float[SIZE_GEOMAGNETIC];
final String NO_DATA_COULD_BE_READ = null;
boolean succeeded = SensorManager.getRotationMatrix(NOT_USED, NOT_USED, outGravity, outGeomagnetic);
if (!succeeded)
{
    return NO_DATA_COULD_BE_READ;
}

Log.v("Test", "This should be printed - but it isn't!!");

// Prepare the data to return.
final int X = 0, Y = 1, Z = 2;
final String FIELD_SEPARATOR = ",", VECTOR_SEPARATOR = ";";
String returnValue = "" +
    outGravity[X] + FIELD_SEPARATOR +
    outGravity[Y] + FIELD_SEPARATOR +
    outGravity[Z] + VECTOR_SEPARATOR + 
    outGeomagnetic[X] + FIELD_SEPARATOR +
    outGeomagnetic[Y] + FIELD_SEPARATOR +
    outGeomagnetic[Z];

// Return data.
return returnValue;

SensorManager.getRotationMatrix(...)收益,Eclipse调试器显示,if语句上面写着 突然跳跃到返回的returnValue如果(成功了!); 。没有抛出异常,并且LogCat中 - 即使是在详细模式 - 没有收到不寻常的消息。它甚至没有收到我放在code中的消息。我尝试了明显的清洁和重启-Eclipse的方法,并没有帮助。我很困惑。

When SensorManager.getRotationMatrix(...) returns false, the Eclipse debugger shows that the if-statement that says if (!succeeded) suddenly jumps to return returnValue;. No exception is thrown and LogCat - even on verbose mode - receives no unusual message. It doesn't even receive the message I put in the code. I tried the obvious clean-and-restart-Eclipse approach and that didn't help. I'm very confused.

Eclipse调试器告诉我,第二个收益语句被调用。然而,把更多的打印报表中显示,第一收益语句实际上是被达到的。也许我穿过一个Eclipse错误绊倒?或任何人可以解释这一异常现象?

The Eclipse debugger is telling me that the second return statement is being called. However, putting additional print statements in shows that the first return statement is actually the one being reached. Perhaps I've stumbled across an Eclipse bug? Or anyone could explain this anomaly?

推荐答案

你怎么确保它跳转到最后收益?你在一个收益如果,这很有可能是这一个被称为

How are you sure that it jumps to the last return? You have a return in the if, this is most likely this one which is called.

这篇关于Eclipse调试器是跳跃到错误return语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆