Community
Participate
Working Groups
It seems too eager when @NonNullByDefault(TYPE_ARGUMENT) leads to the assumption that map.get(someValue) will always return a non-null value. My code: private Map<String, BundleFrequency> bundles = Maps.newTreeMap(); @Nullable BundleFrequency frequency = bundles.get(key(bundle)); // this can be null (frequency == null) { // here the compiler complains frequency cannot be null frequency = new BundleFrequency(bundle.getName(), bundle.getVersion(), 0); bundles.put(key(bundle), frequency); } The same will likely happen for list.get(index) and other methods.
Have a look at http://www.eclipse.org/eclipse/news/4.5/jdt.php#annotate-command Your's was the exact example I used to motivate and explain external annotations. Map.get() returns T and if T="@NonNull Something" than Map.get() declares to return "@NonNull Somthing". That's how generics work. That declaration is "wrong". Then only way to fix is to fix the signature of Map.get(). You can do that since Mars. *** This bug has been marked as a duplicate of bug 331651 ***