Given Java source code and a preprocessor (like C++), I would like to replace all mentions of null with a function that returns null. It finds a call to null and replaces it with the following function.

```
public static Object returnNull(){
    return null;
}

```

This fails because there are varied classes and:

```
functionThatWantsCustomClass( returnNull() ); //Object cannot be converted to CustomClass

```

or

```
if( cc == returnNull() ) //Object cannot be converted to CustomClass

```

etc.

Easiest solution I can imagine is having to parametrize the preprocessor, although that would require going through every single null to add the parameter maually, eg: `null/*CustomClass*/`.

Another method is spending a lot of time writing a much better parser so it always knows the required class for a returnTypedNull() function.

Is there a way to get through this error with minimal modification/parsing?