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

Bug 500157

Summary: [null] Wrong "Dead code" warning
Product: [Eclipse Project] JDT Reporter: Dirk Fauth <dirk.fauth>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact: Stephan Herrmann <stephan.herrmann>
Severity: normal    
Priority: P3 CC: frank.rene.benoit, gautier.desaintmartinlacaze, manoj.palat, stephan.herrmann
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard: stalebug

Description Dirk Fauth CLA 2016-08-23 15:20:27 EDT
In one of my Java source files [1] I get a "Dead code" warning for a line of code that is definitely not dead and executed at runtime.

Seems to be related to null analysis. The field that is checked is initialized with null and set within a nested for loop. I tried to set the value in the outer for loop and the warning vanishes. If I set the value only in the inner for loop (which is the required scenario) the warning appears.

[1] http://git.eclipse.org/c/nattable/org.eclipse.nebula.widgets.nattable.git/tree/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/FillHandleLayerPainter.java
Comment 1 Stephan Herrmann CLA 2016-08-24 06:31:03 EDT
Could you please tell us which exact code location triggers the problem.
Obviously, an isolated example would be ideal for investigation.
Comment 2 Dirk Fauth CLA 2016-08-24 09:30:26 EDT
(In reply to Stephan Herrmann from comment #1)
> Could you please tell us which exact code location triggers the problem.
> Obviously, an isolated example would be ideal for investigation.

Sorry, I thought I posted the line numbers.

The warning is raised on line 378.
The fillHandleCell variable is set on line 302. This code is exactly executed once at the end of the for loop. So it is definitely no dead code.

I tried to provoke the warning with a similar isolated code, but I am not able to reproduce the issue this way. I really don't understand which side effect causes that warning.
Comment 3 Stephan Herrmann CLA 2016-08-25 12:45:30 EDT
(In reply to Dirk Fauth from comment #2)
> (In reply to Stephan Herrmann from comment #1)
> > Could you please tell us which exact code location triggers the problem.
> > Obviously, an isolated example would be ideal for investigation.
> 
> Sorry, I thought I posted the line numbers.
> 
> The warning is raised on line 378.
> The fillHandleCell variable is set on line 302.

Thanks

> I tried to provoke the warning with a similar isolated code, but I am not
> able to reproduce the issue this way. I really don't understand which side
> effect causes that warning.

mh, investigation will not be easy then ...
Comment 4 Frank Benoit CLA 2016-12-07 09:24:35 EST
Hello Dirk, hello Stephan,

I have also such a dead code warning, also when working with the null analysis. 

And i have SonarLint active, perhaps it is related to it. Dirk, do you have use SonarLint too?

However, closed and rebuild with another Eclipse 4.6.1 without SonarLint, warning is gone. Back to Eclipse with SonarLint, the project clean, the warning stays away. :-/

I there a way to get helpful information? logs or something?

Frank
Comment 5 Stephan Herrmann CLA 2016-12-07 14:29:57 EST
Fankly, I have no idea how SonarLint interacts with JDT. You?
Comment 6 Dirk Fauth CLA 2016-12-07 14:32:31 EST
No I don't use SonarLint. 

I have used an old workspace in a committers version of the IDE. 

Could it be an issue with older workspaces?
Comment 7 Dirk Fauth CLA 2017-01-18 02:33:40 EST
Today I checked with a current Oxygen build if this issue still occurs. But magically the wrong dead code warning disappeared. I can't tell what I have done in the meantime, if it was somehow fixed in JDT or if the workspace was corrupted and somehow corrected.

But as I can't reproduce the issue anymore and it also doesn't appear in my workspaces anymore, I would be fine with closing this ticket.
Comment 8 Stephan Herrmann CLA 2017-01-18 16:54:01 EST
(In reply to Dirk Fauth from comment #7)
> Today I checked with a current Oxygen build if this issue still occurs. But
> magically the wrong dead code warning disappeared. I can't tell what I have
> done in the meantime, if it was somehow fixed in JDT or if the workspace was
> corrupted and somehow corrected.
> 
> But as I can't reproduce the issue anymore and it also doesn't appear in my
> workspaces anymore, I would be fine with closing this ticket.

Thanks.

@Frank, are you still seeing wrong warnings?
Comment 9 Frank Benoit CLA 2017-01-23 16:09:37 EST
I have lots of warnings due to the eea paths in Bug 509715.
I will tell with M5 on Friday.
Comment 10 Manoj N Palat CLA 2018-05-16 01:06:25 EDT
bulk move out of 4.8
Comment 11 Eclipse Genie CLA 2020-05-14 03:36:36 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.