MCPcopy Index your code
hub / github.com/apache/tomcat / invoke

Method invoke

java/jakarta/el/StaticFieldELResolver.java:84–137  ·  view source on GitHub ↗
(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params)

Source from the content-addressed store, hash-verified

82
83
84 @Override
85 public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) {
86 Objects.requireNonNull(context);
87
88 if (base instanceof ELClass && method instanceof String methodName) {
89 context.setPropertyResolved(base, method);
90
91 Class<?> clazz = ((ELClass) base).getKlass();
92
93 if ("<init>".equals(methodName)) {
94 Constructor<?> match = Util.findConstructor(context, clazz, paramTypes, params);
95
96 Object[] parameters =
97 Util.buildParameters(context, match.getParameterTypes(), match.isVarArgs(), params);
98
99 Object result;
100 try {
101 result = match.newInstance(parameters);
102 } catch (InvocationTargetException e) {
103 Throwable cause = e.getCause();
104 Util.handleThrowable(cause);
105 throw new ELException(cause);
106 } catch (ReflectiveOperationException e) {
107 throw new ELException(e);
108 }
109 return result;
110
111 } else {
112 // Static method so base should be null
113 Method match = Util.findMethod(context, clazz, null, methodName, paramTypes, params);
114
115 if (match == null) {
116 throw new MethodNotFoundException(
117 Util.message(context, "staticFieldELResolver.methodNotFound", methodName, clazz.getName()));
118 }
119
120 Object[] parameters =
121 Util.buildParameters(context, match.getParameterTypes(), match.isVarArgs(), params);
122
123 Object result;
124 try {
125 result = match.invoke(null, parameters);
126 } catch (IllegalArgumentException | IllegalAccessException e) {
127 throw new ELException(e);
128 } catch (InvocationTargetException e) {
129 Throwable cause = e.getCause();
130 Util.handleThrowable(cause);
131 throw new ELException(cause);
132 }
133 return result;
134 }
135 }
136 return null;
137 }
138
139 @Override
140 public Class<?> getType(ELContext context, Object base, Object property) {

Callers 6

testInvoke01Method · 0.95
testInvoke02Method · 0.95
testInvoke03Method · 0.95
testInvoke08Method · 0.95
doNegativeTestMethod · 0.95
doThrowableTestMethod · 0.95

Calls 14

findConstructorMethod · 0.95
buildParametersMethod · 0.95
handleThrowableMethod · 0.95
findMethodMethod · 0.95
messageMethod · 0.95
getKlassMethod · 0.80
equalsMethod · 0.65
newInstanceMethod · 0.65
getNameMethod · 0.65
invokeMethod · 0.65
setPropertyResolvedMethod · 0.45
getParameterTypesMethod · 0.45

Tested by 6

testInvoke01Method · 0.76
testInvoke02Method · 0.76
testInvoke03Method · 0.76
testInvoke08Method · 0.76
doNegativeTestMethod · 0.76
doThrowableTestMethod · 0.76