The problem is in the return type of the Calc
method that is a primitive Int32
. Once you are not specifying the returned value in your interceptor then it will return null
and thus, when the proxy tries to convert that value to Int32
it will throw a NullPointerException
.
To fix the problem you should set the return value in the intercept
method, e.g. invocation.ReturnValue = 0;