Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 481913

Summary: [compiler][null] Allow to specify that repeated calls will return the same results (e.g., for getters)
Product: [Eclipse Project] JDT Reporter: Marcel Bruch <marcel.bruch>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 4.5.1   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Marcel Bruch CLA 2015-11-11 04:21:05 EST
My code makes an explicit null check:

 if (problem.getBug() != null && problem.getBug().getBugId() == 0) {


Since #getBug() is a getter and no subsequent call like #setBug() happened, null analysis should assume that #getBug() will not be null when called the second time.

It's clear to me that generally assuming that a method will be idempotent (as long as no other call on the receiver was made) would be a strong claim. However, it might be valid to allow a API providers to specify that behavior via annotation attributes. E.g. via @Nullable(idempotent=true) Bug getBug()


(not sure idempotent is the correct word to use here).

WDYT?
Comment 1 Stephan Herrmann CLA 2015-11-11 18:57:40 EST
(In reply to Marcel Bruch from comment #0)
> WDYT?

local variable