DLS_DEAD_LOCAL_STORE SuppressWarnings FindBugs false positive

I am trying to rule out a false positive for DLS_DEAD_LOCAL_STORE

Here is what I have tried so far:

@SuppressWarnings("DLS_DEAD_LOCAL_STORE") 

@edu.umd.cs.findbugs.annotations.SuppressWarnings("DLS_DEAD_LOCAL_STORE")

(based on Deny actions not working on FindBugs )

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "DLS_DEAD_LOCAL_STORE", justification = "please go away")

based on http://osdir.com/ml/java-findbugs-general/2010-06/msg00017.html

But none of the options help. Please advise. Using Eclipse Indigo.

+4
source share
3 answers

Googling + Experimenting more, and I finally figured out how to do this.

Check Section 6 under http://findbugs.sourceforge.net/manual/filter.html .

You need to create your own XML file with all custom labels. Then you need the build.xml file to find out about this file through findbugs.exclude.filter

  <Match> <Class name="com.foobar.MyClass" /> <Method name="someMethod" /> <Bug pattern="DLS_DEAD_LOCAL_STORE" /> </Match> 

You do not need to add the @SuppressWarnings tag to a method as soon as it is in XML.

Hope this helps someone!

+6
source

I had the same problem with this code:

 @Test public void testSomething() { @SuppressWarnings("unused") @SuppressFBWarnings(value = "DLS_DEAD_LOCAL_STORE") final SomeMockClass mock = new SomeMockClass(); ... } } 

@SuppressFBWarnings doesn't work here.

The solution here was to move @SuppressFBWarnings to the method level:

 @Test @SuppressFBWarnings(value = "DLS_DEAD_LOCAL_STORE") public void testSomething() { @SuppressWarnings("unused") final SomeMockClass mock = new SomeMockClass(); ... } } 

I like to limit the volume of these annotations as little as possible, so they do not suppress real problems. Here, it seems necessary to annotate the whole method.

+3
source

As explained in the FindBugs documentation , it is obvious that the Sun / Oracle javac compiler often generates dead repositories for local final variables. These DLS_DEAD_LOCAL_STORE warnings cannot be easily suppressed.

Not sure why the XML filter works (as in the accepted answer).

+2
source

Source: https://habr.com/ru/post/1492812/


All Articles