@@ -245,12 +245,17 @@ public static JSONObject invokeMethod(JSONObject req, Object instance) {
245
245
if (clazz == null ) {
246
246
throw new ClassNotFoundException ("找不到 " + dot2Separator (pkgName ) + "/" + clsName + " 对应的类!" );
247
247
}
248
+
248
249
if (instance == null && req .getBooleanValue ("static" ) == false ) {
249
250
instance = getInvokeInstance (clazz , getArgList (req , "classArgs" ));
250
251
}
251
252
253
+ JSONObject ir = getInvokeResult (clazz , instance , methodName , getArgList (req , "methodArgs" ));
254
+
252
255
result = CALLBACK .newSuccessResult ();
253
- result .put ("invoke" , getInvokeResult (clazz , instance , methodName , getArgList (req , "methodArgs" )));
256
+ result .put ("invoke" , ir == null ? null : ir .get ("invoke" ));
257
+ result .put ("types" , ir == null ? null : ir .get ("types" ));
258
+ result .put ("args" , ir == null ? null : ir .get ("args" ));
254
259
result .put ("instance" , instance );
255
260
}
256
261
catch (Exception e ) {
@@ -413,7 +418,7 @@ public static Method getInvokeMethod(Class<?> clazz, String methodName, List<Arg
413
418
* @return
414
419
* @throws Exception
415
420
*/
416
- public static Object getInvokeResult (Class <?> clazz , Object instance , String methodName , List <Argument > methodArgs ) throws Exception {
421
+ public static JSONObject getInvokeResult (Class <?> clazz , Object instance , String methodName , List <Argument > methodArgs ) throws Exception {
417
422
Objects .requireNonNull (clazz );
418
423
Objects .requireNonNull (methodName );
419
424
@@ -427,8 +432,11 @@ public static Object getInvokeResult(Class<?> clazz, Object instance, String met
427
432
initTypesAndValues (methodArgs , types , args , true );
428
433
}
429
434
430
- //TODO method 也缓存起来
431
- return clazz .getMethod (methodName , types ).invoke (instance , args );
435
+ JSONObject result = new JSONObject ();
436
+ result .put ("invoke" , clazz .getMethod (methodName , types ).invoke (instance , args ));
437
+ result .put ("types" , types );
438
+ result .put ("args" , args );
439
+ return result ;
432
440
}
433
441
434
442
0 commit comments