Could we please throw an exception in a proxy if the return value is null and should be a primitive type?
It is extremely hard to debug at present if you happen to intercept a method that returns a primitive type, and the proxy then returns null. The stack trace has no useful line numbers in it (since it comes from the $Proxy) and there is no way to know what you have done wrong. Wouldn't it be worth the cost of a check for null if the type is primitive (e.g. in JdkDynamicAopProxy after the call to invocation.proceed())? Probably it would be no more expensive than the existing special case there already for detecting "return this".