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

Bug 315387

Summary: [null][compiler][correlation] Helios is flagging a potential NPE in a context where it can't occur. Galileo handles this context correctly.
Product: [Eclipse Project] JDT Reporter: Missing name <avantnoisebot>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: REOPENED --- QA Contact:
Severity: minor    
Priority: P3 CC: manoj.palat, Olivier_Thomann, stephan.herrmann
Version: 3.6Keywords: helpwanted
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard: stalebug

Description Missing name CLA 2010-06-02 08:36:25 EDT
Helios is flagging a potential NPE in a context where it can't occur.  Galileo handles this correctly.
Example:

   if (initStart == null || initEnd == null) {
         // if both null, default end to now and subtract an hour for start
         if (initStart == null && initEnd == null) {
            // default end to when the editor was launched
            initEnd = editorLaunchDate;
            // subtract an hour from end for start
            long timeInMillis = initEnd.getTime() + ONE_HOUR_MILLIS;
            initStart = new Date(timeInMillis);
         } else if (initStart == null) {
            // subtract an hour from end for start
            /***** Helios says initEnd could be null here, but in fact the logic makes that impossible *****/
            long timeInMillis = initEnd.getTime() - ONE_HOUR_MILLIS;
            initStart = new Date(timeInMillis);
         } else {
            // add an hour to start for end
            long timeInMillis = initStart.getTime() + ONE_HOUR_MILLIS;
            initEnd = new Date(timeInMillis);
         }
      }


-- Configuration Details --
Product: Eclipse 1.3.0.20100526-1935 (org.eclipse.epp.package.java.product)
Installed Features:
 org.eclipse.jdt 3.6.0.v20100520-0800-7z8XFUJFMTfCW8oRvdJkums9H155
Comment 1 Olivier Thomann CLA 2010-06-02 11:47:49 EDT
Ayushman, please investigate
Comment 2 Stephan Herrmann CLA 2016-06-28 17:30:42 EDT
While bulk closing [null][correlation] bugs, I was intrigued by the observation that this had been working as desired in Galileo (3.5).

Then I changed the code to

//---
  void test (Date initStart, Date initEnd, Date editorLaunchDate, boolean b) {
    
   if (initStart == null || initEnd == null) {
         // if both null, default end to now and subtract an hour for start
         if (initStart == null && b) { // ****CHANGED*****
            // default end to when the editor was launched
            initEnd = editorLaunchDate;
            // subtract an hour from end for start
            long timeInMillis = initEnd.getTime() + ONE_HOUR_MILLIS;
            initStart = new Date(timeInMillis);
         } else if (initStart == null) {
            // subtract an hour from end for start
            /***** Helios says initEnd could be null here, but in fact the logic makes that impossible *****/
            long timeInMillis = initEnd.getTime() - ONE_HOUR_MILLIS;
            initStart = new Date(timeInMillis);
         } else {
            // add an hour to start for end
            long timeInMillis = initStart.getTime() + ONE_HOUR_MILLIS;
            initEnd = new Date(timeInMillis);
         }
      }
  }
//---

thusly removing the check that should protect initEnd. Still Galileo kept quiet, so maybe the analysis back then wasn't better but simply incomplete ...

Still, might be worth a third look during the Oxygen cycle, before closing either way.
Comment 3 Manoj N Palat CLA 2018-05-17 03:20:35 EDT
bulk move out of 4.8
Comment 4 Stephan Herrmann CLA 2020-06-10 03:34:39 EDT
.
Comment 5 Eclipse Genie CLA 2022-07-11 18:31:10 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.