jfinal enjoy 3.5
This commit is contained in:
@@ -33,7 +33,7 @@ import com.jfinal.template.stat.Scope;
|
||||
* 如果在未来通过结合 #dynamic(boolean) 指令来优化,需要在 Ctrl 中引入一个
|
||||
* boolean dynamic = false 变量,而不能在 Env、Scope 引入该变量
|
||||
*
|
||||
* 还需要引入一个 NullMethodInfo 以及 isNull() 方法,此优化复杂度提高不少,
|
||||
* 还需要引入一个 NullMethodInfo 以及 notNull() 方法,此优化复杂度提高不少,
|
||||
* 暂时不做此优化
|
||||
*/
|
||||
public class Method extends Expr {
|
||||
@@ -76,28 +76,26 @@ public class Method extends Expr {
|
||||
}
|
||||
|
||||
Object[] argValues = exprList.evalExprList(scope);
|
||||
MethodInfo methodInfo;
|
||||
try {
|
||||
methodInfo = MethodKit.getMethod(target.getClass(), methodName, argValues);
|
||||
} catch (Exception e) {
|
||||
throw new TemplateException(e.getMessage(), location, e);
|
||||
}
|
||||
if (methodInfo == null) {
|
||||
|
||||
MethodInfo methodInfo = MethodKit.getMethod(target.getClass(), methodName, argValues);
|
||||
if (methodInfo != null) {
|
||||
return methodInfo.invoke(target, argValues);
|
||||
}
|
||||
|
||||
if (scope.getCtrl().isNullSafe()) {
|
||||
return null;
|
||||
}
|
||||
throw new TemplateException(buildMethodNotFoundSignature("public method not found: " + target.getClass().getName() + ".", methodName, argValues), location);
|
||||
}
|
||||
|
||||
try {
|
||||
return methodInfo.invoke(target, argValues);
|
||||
|
||||
} catch (TemplateException e) {
|
||||
throw e;
|
||||
} catch (ParseException e) {
|
||||
throw e;
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable t = e.getTargetException();
|
||||
if (t != null) {
|
||||
throw new TemplateException(t.getMessage(), location, t);
|
||||
} else {
|
||||
throw new TemplateException(e.getMessage(), location, e);
|
||||
}
|
||||
if (t == null) {t = e;}
|
||||
throw new TemplateException(t.getMessage(), location, t);
|
||||
} catch (Exception e) {
|
||||
throw new TemplateException(e.getMessage(), location, e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user