The outcome of passing null as a parameter is independent of the actions of the method for which it is an argument, but instead depends on the ability of the return datatype to deliver a null value.
You cannot pass the null value as a parameter to a Java scalar type method; Java scalar types are always non-nullable. However, Java object types can accept null values.
For the following Java-SQL class:
public class General implements java.io.Serializable { public static int identity1(int I) {return I;} public static java.lang.Integer identity2 (java.lang.Integer I) {return I;} public static Address identity3 (Address A) {return A;} }
Consider these calls:
declare @I int declare @A Address;
select @I = General.identity1(@I) select @I = General.identity2(new java.lang.Integer(@I)) select @A = General.identity3(@A)
The values of both variable @I and variable @A are null, since values have not been assigned to them.
The call of the identity1( ) method raises an exception. The datatype of the parameter @I of identity1( ) is the Java int type, which is scalar and has no null state. An attempt to pass a null valued argument to identity1( ) raises an exception.
The call of the identity2( ) method succeeds. The datatype of the parameter of identity2( ) is the Java class java.lang.Integer, and the new expression creates an instance of java.lang.Integer that is set to the value of variable @I.
The call of the identity3( ) method succeeds.
A successful call of identity1( ) never returns a null result because the return type has no null state. A null cannot be passed directly because the method resolution fails without parameter type information.
Successful calls of identity2( ) and identity3( ) can return null results.