开发者

Explanation needed on boolean methods return

I've been looking through some code from a decompiled APK file and ran across this syntax for returning a boolean condition that I haven't seen before. Anyone have an explanation on how this works?

public static boolean is2G(NetworkType paramNetworkType)
{
    if ((EDGE.equals(paramNetworkType)) || (IDEN.equals(paramNetworkType)) || (CDMA.equals(paramNetworkType)) || (GPRS.equals(paramNetworkType)));
    for (int i =开发者_运维技巧 1; ; i = 0)
        return i;
}


This composed conditions means if any or all of these 4 conditions are true the whole condition is true.

But the condition body is empty, so nothing happens afterwards. The loop is nevertheless executed independent of the condition.

But you should also be aware that the decompiling is sometimes not working exactly, so maybe it is a decompiling error. This assumption is even more true if you look at the incorrect return type. So even if this code is widely used through the whole application I would suggest a decompiling problem.


OK this is weird.

The condition doesn't do anything at all. It's like

if (condition) {
}

The loop condition says "execute forever"

The loop body says "return right away", but it's returning THE WRONG TYPE!!! How can this even compile?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜