196 assertNotNull(res); |
196 assertNotNull(res); |
197 if (value != null) { |
197 if (value != null) { |
198 assertEquals(res, value); |
198 assertEquals(res, value); |
199 } |
199 } |
200 } catch (InvocationTargetException | IllegalAccessException e) { |
200 } catch (InvocationTargetException | IllegalAccessException e) { |
201 fail("Unexpected exception thrown: " + e.getCause()); |
201 fail("Unexpected exception thrown: " + e.getCause(), e.getCause()); |
202 } |
202 } |
203 } |
203 } |
204 |
204 |
205 /** |
205 /** |
206 * Creates a class which calls target::method(args) via invokevirtual, |
206 * Creates a class which calls target::method(args) via invokevirtual, |
225 /** |
225 /** |
226 * Convenience method for above, which assumes stdMethodName, |
226 * Convenience method for above, which assumes stdMethodName, |
227 * a return type of 'int', and no arguments. |
227 * a return type of 'int', and no arguments. |
228 */ |
228 */ |
229 public void assertInvokeVirtualEquals(int value, Class target) { |
229 public void assertInvokeVirtualEquals(int value, Class target) { |
230 assertInvokeVirtualEquals( |
230 assertInvokeVirtualEquals(value, target, stdCM, "-1"); |
231 new Integer(value), target, stdCM, "-1"); |
|
232 } |
231 } |
233 |
232 |
234 /** |
233 /** |
235 * Creates a class which calls target::method(args) via invokeinterface |
234 * Creates a class which calls target::method(args) via invokeinterface |
236 * through 'iface', compiles and loads both it and 'target', and |
235 * through 'iface', compiles and loads both it and 'target', and |
258 int value, Class target, Interface iface) { |
257 int value, Class target, Interface iface) { |
259 |
258 |
260 Compiler compiler = compilerLocal.get(); |
259 Compiler compiler = compilerLocal.get(); |
261 compiler.setFlags(compilerFlags()); |
260 compiler.setFlags(compilerFlags()); |
262 |
261 |
263 assertInvokeInterfaceEquals( |
262 assertInvokeInterfaceEquals(value, target, new Extends(iface), stdAM); |
264 new Integer(value), target, new Extends(iface), stdAM); |
|
265 |
263 |
266 compiler.cleanup(); |
264 compiler.cleanup(); |
|
265 } |
|
266 |
|
267 protected void assertInvokeInterfaceThrows(java.lang.Class<? extends Throwable> errorClass, |
|
268 Class target, Extends iface, AbstractMethod method, |
|
269 String... args) { |
|
270 try { |
|
271 assertInvokeInterfaceEquals(0, target, iface, method, args); |
|
272 fail("Expected exception: " + errorClass); |
|
273 } |
|
274 catch (AssertionError e) { |
|
275 Throwable cause = e.getCause(); |
|
276 if (cause == null) |
|
277 throw e; |
|
278 else if ((errorClass.isAssignableFrom(cause.getClass()))) { |
|
279 // this is success |
|
280 return; |
|
281 } |
|
282 else |
|
283 throw e; |
|
284 } |
267 } |
285 } |
268 |
286 |
269 /** |
287 /** |
270 * Creates a class which calls target::method(args) via invokevirtual, |
288 * Creates a class which calls target::method(args) via invokevirtual, |
271 * compiles and loads both the new class and 'target', and then invokes |
289 * compiles and loads both the new class and 'target', and then invokes |