History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEABKL-3566
Type: New Feature New Feature
Status: Open Open
Priority: Normal Normal
Assignee: Unassigned
Reporter: Dirk Dittert
Votes: 0
Watchers: 2
Available Workflow Actions

Mark as Stalled
Operations

If you were logged in you would be able to see more operations.
IDEA: Backlog

@Nullable/@NotNull should consider method calls

Created: 15 Dec 05 11:55   Updated: 23 Dec 05 02:56
Component/s: Code Analysis. Inspection
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 4,069


 Description  « Hide
Code analysis and the @Nullable/@NotNull annotations do not consider method calls when checking for null. This is a problem if initialization of objects is deferred with an init method or if return values are cached (that is, in the example below, init would be called if the internal state changed). This kind of defeats the purpose of those annotations as one gets a lot of false positives.
@Nullable
    static Object test = null;

    private static void test() {
        init();
        test.toString();  // marked as may throw NullPointerException
    }

    private static void init() {
        test = new Object();
    }


 All   Comments   Work Log   Change History      Sort Order:
Eugene Vigdorchik - 15 Dec 05 12:22
The whole point of these annotations is to allow intra-method analysis only. Probably the system now lacks some expressivity,
but that is rather a question of adding some further annotations.

Dirk Dittert - 15 Dec 05 13:39
This is, why I filed this issue as "New Feature", not as "Bug"

Maxim Shafirov - 23 Dec 05 02:35
Well, while this sounds reasonable I hardly beleive it's possible to implement interprocedural DFA, which has reasonable performance to be used in on the fly editor highlighting unless machines become 1000 times more powerful.

Keith Lea - 23 Dec 05 02:56
What about heuristic simply scanning tree of each called method for field assignment?