Java JSONObject#has throwing exception

Question!

I'm trying to check if a JSONObject has a specific key. Here is my code:

    JSONObject meta = App.meta();
    int sum = 0;
    JSONObject mapping;
    if(!meta.has("readMessagesMap")){  <--- this line jumps to...
        return 0;        <--- never called
    }else{
        try { <--- never called
            mapping = meta.getJSONObject("readMessagesMap");
            [...]
            return sum;
        } catch (JSONException e) {
            e.printStackTrace();
            return 0; <--- ...directly to here
        }
    }

meta is a valid JSONObject:

enter image description here

When I'm stepping, the if statement, somehow, directly jumps to return 0 line inside the catch block, without even entering try block. I have breakpoints on the try line, e.printStackTrace line, they are just not called. The stack trace isn't printed either. I have no idea why this is happening. I've restarted Android Studio and my app, but it's the same.



Answers

It was a symbol corruption issue. I've cleaned the project and it got away.



This video can help you solving your question :)
By: admin