/** * Returns a class which has a static method with the same name as 'method', whose body creates an * new instance of 'specimen', casts it to 'iface' (including the type parameters) and invokes * 'method' upon it via an invokeinterface instruction with 'args' as function call parameters. */ private Class invokeInterfaceHarness( Class specimen, Extends iface, AbstractMethod method, String... args) { Interface istub = new Interface( iface.getType().getName(), iface.getType().getAccessFlags(), iface.getType().getParameters(), null, Arrays.asList((Method) method)); Class cstub = new Class(specimen.getName()); String params = toJoinedString(args, ", "); ConcreteMethod sm = new ConcreteMethod( "int", SourceModel.stdMethodName, String.format( "return ((%s)(new %s())).%s(%s);", iface.toString(), specimen.getName(), method.getName(), params), new AccessFlag("public"), new AccessFlag("static")); sm.suppressWarnings(); Class ii = new Class("II_" + specimen.getName() + "_" + iface.getType().getName(), sm); ii.addCompilationDependency(istub); ii.addCompilationDependency(cstub); ii.addCompilationDependency(method); return ii; }