patterntesting.check.runtime
Aspect AbstractNullPointerTrap

java.lang.Object
  extended by patterntesting.check.runtime.AbstractNullPointerTrap
Direct Known Subclasses:
NullPointerTrap

public abstract aspect AbstractNullPointerTrap
extends java.lang.Object

What is the difference to the AbstractNullTest aspect? In the AbstractNullTest aspect we log only if a null value is given to a method. The NullPointerTrap here is much stricter: it requires that

As in AbstractNullTest you can define exceptions from these strict rules by defining the abstract pointcuts applicationCode, nullArgsAllowed and mayReturnNull. This aspect is intended more for finding bugs in the test phase whereas AbstractNullTest can be also used during production because it logs only the problematic calls with a null parameter.

Since:
11.12.2007

Pointcut Summary
public applicationCode()
            Specify what the application code is that should be subject to the pattern test.

public nullArgsAllowed()
            Specify which code is allowed to have null parameters.

public mayReturnNull()
            Specify which methods may return null.

(package private) invalidNullParameter()
            Addresses all methods (or constructors) with at least one argument which should not be given as null parameter.

 

Advice Summary
before(): invalidNullParameter..
            If a (null) parameter is detected something is wrong with the application code.

 Advises:patterntesting.check.runtime.junit.JUnit3Runner.setUp, patterntesting.check.runtime.junit.JUnit3Runner.tearDown, patterntesting.check.runtime.junit.JUnit4Runner.setUp, patterntesting.check.runtime.junit.JUnit4Runner.tearDown, patterntesting.check.runtime.DeprecatedCodeException.DeprecatedCodeException
afterReturning(java.lang.Object): nonVoidMethods..
 
 Advises:patterntesting.check.runtime.DeprecatedAspect.getLog

 

Field Summary
protected static boolean assertEnabled
          
 
Constructor Summary
AbstractNullPointerTrap()
           
 
Method Summary
abstract  org.apache.commons.logging.Log getLog()
           To get the aspect specific logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

 

Pointcut Detail

applicationCode()

Specify what the application code is that should be subject to the pattern test.
Ex: pointcut applicationCode(): within(patterntesting.sample.*)


nullArgsAllowed()

Specify which code is allowed to have null parameters.
Ex: execution(@NullArgsAllowed * *..*(*, ..)) || execution(@NullArgsAllowed *..new(*, ..))


mayReturnNull()

Specify which methods may return null. Some methods (like find methods or getters) may return a null value.
Ex: execution(@MayReturnNull Object+ *..*(..))


invalidNullParameter()

Addresses all methods (or constructors) with at least one argument which should not be given as null parameter. For performance reason this is limited only to public methods (or constructors)


 

Advice Detail

before

before(): invalidNullParameter..

If a (null) parameter is detected something is wrong with the application code. Inner classes will be skipped because they are handled different by the compiler (for private static inner classes it adds an additional argument for the default constructor. But this additional argument is always null).

 Advises:patterntesting.check.runtime.junit.JUnit3Runner.setUp, patterntesting.check.runtime.junit.JUnit3Runner.tearDown, patterntesting.check.runtime.junit.JUnit4Runner.setUp, patterntesting.check.runtime.junit.JUnit4Runner.tearDown, patterntesting.check.runtime.DeprecatedCodeException.DeprecatedCodeException


afterReturning

afterReturning(java.lang.Object): nonVoidMethods..

 Advises:patterntesting.check.runtime.DeprecatedAspect.getLog

Field Detail

assertEnabled

protected static final boolean assertEnabled

Constructor Detail

AbstractNullPointerTrap

public AbstractNullPointerTrap()
Method Detail

getLog

public abstract org.apache.commons.logging.Log getLog()
To get the aspect specific logger.

Returns:
the logger