MCPcopy Index your code
hub / github.com/beanshell/beanshell / invokeImpl

Method invokeImpl

src/bsh/XThis.java:145–194  ·  view source on GitHub ↗
( Object proxy, Method method, Object[] args )

Source from the content-addressed store, hash-verified

143 }
144
145 public Object invokeImpl( Object proxy, Method method, Object[] args )
146 throws EvalError
147 {
148 String methodName = method.getName();
149 CallStack callstack = new CallStack( namespace );
150
151 /*
152 If equals() is not explicitly defined we must override the
153 default implemented by the This object protocol for scripted
154 object. To support XThis equals() must test for equality with
155 the generated proxy object, not the scripted bsh This object;
156 otherwise callers from outside in Java will not see a the
157 proxy object as equal to itself.
158 */
159 BshMethod equalsMethod = null;
160 try {
161 equalsMethod = namespace.getMethod(
162 "equals", new Class [] { Object.class } );
163 } catch ( UtilEvalError e ) {/*leave null*/ }
164 if ( methodName.equals("equals" ) && equalsMethod == null ) {
165 Object obj = args[0];
166 return proxy == obj ? Boolean.TRUE : Boolean.FALSE;
167 }
168
169 /*
170 If toString() is not explicitly defined override the default
171 to show the proxy interfaces.
172 */
173 BshMethod toStringMethod = null;
174 try {
175 toStringMethod =
176 namespace.getMethod( "toString", new Class [] { } );
177 } catch ( UtilEvalError e ) {/*leave null*/ }
178
179 if ( methodName.equals("toString" ) && toStringMethod == null)
180 {
181 Class [] ints = proxy.getClass().getInterfaces();
182 // XThis.this refers to the enclosing class instance
183 StringBuffer sb = new StringBuffer(
184 XThis.this.toString() + "\nimplements:" );
185 for(int i=0; i<ints.length; i++)
186 sb.append( " "+ ints[i].getName()
187 + ((ints.length > 1)?",":"") );
188 return sb.toString();
189 }
190
191 Class [] paramTypes = method.getParameterTypes();
192 return Primitive.unwrap(
193 invokeMethod( methodName, Primitive.wrap(args, paramTypes) ) );
194 }
195 };
196}

Callers 1

invokeMethod · 0.95

Calls 10

unwrapMethod · 0.95
wrapMethod · 0.95
getClassMethod · 0.80
appendMethod · 0.80
getNameMethod · 0.45
getMethodMethod · 0.45
equalsMethod · 0.45
toStringMethod · 0.45
getParameterTypesMethod · 0.45
invokeMethodMethod · 0.45

Tested by

no test coverage detected