private void feed(Object ref, Person hlo) { try { Method feed = ReflectionUtils.requireMethod(Reformatory.class, "feed", Person.class); ReflectionUtils.invokeMethod(void.class, feed, ref, hlo); } catch (Throwable t) { } }
private int totalWeightsMeasured(Object ref) { try { Method totalWeightsMeasured = ReflectionUtils.requireMethod(Reformatory.class, "totalWeightsMeasured"); return ReflectionUtils.invokeMethod(int.class, totalWeightsMeasured, ref); } catch (Throwable t) { } return -1; }
private void callMain(Class kl) { try { kl = ReflectionUtils.newInstanceOfClass(kl); String x[] = new String[0]; Method m = ReflectionUtils.requireMethod(kl, "main", x.getClass()); ReflectionUtils.invokeMethod(Void.TYPE, m, null, (Object) x); } catch (NoSuchElementException e) { fail("use Integer.parseInt( reader.nextline() ) to read the numbers"); } catch (Throwable e) { fail("something unexpected happened " + e); } }