Java Developer Tools

Limitations of Dead Code Analyzer Tool

There are two possible situations when dead code analyzer may give false results:

False Positives

In some cases dead code analyzer may incorrectly mark code as dead code, this situations should be very rare and are limited to things like using reflection, JNI, or calls from the program components that are out of the analysis scope.

Main approach that should be used to deal with false positives is accurate selection of analysis scope and application entry points.

False Negatives

In some situations dead code analyzer is unable to prove that code is dead when it actually is. This is caused by existence of situations when static analysis is unable to prove that code is actually dead. Basic example of this situations when some method is referenced but at runtime level this level is never called because of complex conditions in data flow. For example in the following sample method boo is never called actually, but current version of dead code analyzer will not able to prove it.

class SomeClass{
	
	private void boo(){
	  ....
	}
	
	void foo(boolean a,boolean b){
		if (b)
		{
		  a=false;
		  b=false;
		}
	    if (!b)
	    {
	      a=false;
	    }
	    if (a)
	    {
	      boo();	     
	    }
	}
}	
	

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.