This is the Kotlin equivalent of Java code using InvocationHandler
:
override fun invoke(proxy: Any?, method: Method?, args: Array<out Any>?): Any {
println("before httprequest--->" + args)
val ret = method!!.invoke(obj, args)
println("after httprequest--->")
return ret
}
Java code:
public Object invoke(Object o, Method method, Object[] args) throws Throwable {
System.out.println("jdk--------->http" + args);
Object result=method.invoke(target, args);
System.out.println("jdk--------->http");
return result;
}
In both case args
is null , But if I run it, Kotlin code is giving Exception
Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments
What is the cause of this as Kotlin is using the standard Java class?