patterntesting.java.runtime
Aspect AbstractNullPointerTrap

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

public abstract aspect AbstractNullPointerTrap
extends java.lang.Object

 

Advice Detail

before

before(): invalidNullParameter..

If a (null) parameter is detected something is wrong with the application code

 Advises:patterntesting.java.runtime.AbstractNullPointerTrapTest.acceptNoNullArg


afterReturning

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

A 'null' as return value is often an indication that something is wrong (otherwise an exception should be thrown)

 Advises:patterntesting.java.runtime.AbstractNullPointerTrapTest.getUnallowedNullString

 

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.


mayReturnNull()

Specify which methods may return null. Some methods (like find methods or getters) may return a null value.


invalidNullParameter()

Addresses all methods (or constructors) with at least one argument with should not be given as null parameter


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
See Also:
AbstractNullTestTest

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 with 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.java.runtime.AbstractNullPointerTrapTest.acceptNoNullArg
afterReturning(java.lang.Object): nonVoidMethods..
            A 'null' as return value is often an indication that something is wrong (otherwise an exception should be thrown)

 Advises:patterntesting.java.runtime.AbstractNullPointerTrapTest.getUnallowedNullString

 

Constructor Summary
AbstractNullPointerTrap()
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractNullPointerTrap

public AbstractNullPointerTrap()