Bug 126551 - [compiler] null reference analysis: add interprocedural analysis
Summary: [compiler] null reference analysis: add interprocedural analysis
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC All
: P3 normal with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 154191 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-02-06 08:23 EST by Tom Hofmann CLA
Modified: 2010-09-30 07:48 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2006-02-06 08:23:28 EST
From bug 110030 comment 6:

A) A method or statement 'certifies' a reference' null state

A frequent pattern when dealing with references is to rely on methods throwing an exception if a null check fails. Null reference analysis could try to find out that the reference to 'o' is not null in the following example:

void m(Object o) {
  Assert.isNotNull(o);
  o.toString(); // warning
}

--

B) the return value of a method is known to be non-null

Another pattern is to have a method that returns a value that is guaranteed to be non null:

void m(Object o) {
  o= objectOrDummy(o);
  o.toString();
}

Object objectOrDummy() {
  if (o == null)
    return new NullObject();
  return o;
}
Comment 1 Stefan Matthias Aust CLA 2006-02-15 05:13:35 EST
If not doing a full features analysis, it might be a suficient hack to simply know that a few method will throw exceptions or otherwise will never return, e.g.

 junit.framework.Assert.fail()
 java.lang.System.exit()

Especially for unit tests, it might be a good idea if the analyser simply knows the semantics of junit assert methods because that is kind-of an industry standard.
Comment 2 Maxime Daniel CLA 2006-02-16 04:36:05 EST
*** Bug 127575 has been marked as a duplicate of this bug. ***
Comment 3 Tom Hofmann CLA 2006-02-16 05:06:20 EST
Implementing this without an annotation mechanism similar to @NotNull / @Nullable may be hard, as you have to perform arbitrarily complex flow analysis... Annotations would allow to keep the analysis local.
Comment 4 Sarah Gerweck CLA 2006-05-11 16:11:45 EDT
Maybe we can at least add @NotNull and @Nullable (for compatibility with IDEA) and starting dealing with the easiest cases?
Comment 5 Maxime Daniel CLA 2006-08-22 05:24:43 EDT
*** Bug 154191 has been marked as a duplicate of this bug. ***
Comment 6 Maxime Daniel CLA 2006-09-19 02:21:14 EDT
Philippe, I believe we need to discuss what we want to do here.
Comment 7 Philipe Mulet CLA 2006-09-19 03:39:56 EDT
Interprocedural analysis belongs to static analysis, not to compiler.
If information was available from annotations etc... then we could improve our analysis, but we would never consider going interprocedural (simply using better input from message/field expressions, rather than unknown).
Comment 8 Maxime Daniel CLA 2006-09-26 02:26:52 EDT
WONTFIX then.