[ nice-Bugs-1624383 ] A case where nullness inference doesn't quite work
"SourceForge.net" <[email protected]> Fri, 29 Dec 2006 07:11:23 -0800
| Newsgroups | gmane.comp.lang.nice.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1624383, was opened at 2006-12-29 07:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1624383&group_id=12788
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: A case where nullness inference doesn't quite work
Initial Comment:
If you do the following, the nullness inference fails unless you add an assertion:
?Foo bar = null;
bar = myMethod();
doStuff(bar);
Where
public Foo myMethod();
public void doStuff(Foo foo);
The compiler things that foo might be null, and so you can't call doStuff on it.
At least that's what I think is happening. Here's the sample code which this appeared in:
package kakuro;
import java.util.*;
import java.lang.ref.*;
public class CalculationTable<S, T>
{
private HashMap<S, ?SoftReference<T>> values = new HashMap();
private (S -> T) calculate;
public T get(S arg)
{
?SoftReference<T> valueRef = values.get(arg);
?T value;
if (valueRef == null)
{
value = calculate(arg);
}
else
{
value = valueRef.get();
}
if (value == null)
{
value = calculate(arg);
values.put(arg, new SoftReference(value));
}
return value;
}
}
The error occurs with the "new SoftReference(value)".
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1624383&group_id=12788
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV