title: Invoking a method with generic parms using reflection
body: <p>I am trying to pass two generics with known types (<code>accumulationFunction</code>, <code>resultBindings</code>) into the reflective invoke routine below, but I'm having trouble.  Can someone help me understand how this can be achieved?</p>
  
  <pre><code>package com.amir.method.compiler;
  
  //hidden imports
  
  import java.util.Set;
  
  public class CompiledReferencedAttributeMethod implements CompiledMethod {
  
      final Class&lt;?&gt; generatedClazz;
      //how do i pass the arguments below into the invoke routine??
      final KnownWorkData&lt;AccumulationFunction&gt; accumulationFunction;
      final KnownWorkData&lt;Set&lt;Executable&lt;InstanceSetValue&gt;&gt;&gt; resultBindings;
  
      public CompiledReferencedAttributeMethod(final int hash,
                                               final KnownWorkData&lt;AccumulationFunction&gt; accumulationFunction,
                                               final KnownWorkData&lt;Set&lt;Executable&lt;InstanceSetValue&gt;&gt;&gt; resultBindings) {
          this.generatedClazz = ReferencedAttributeMethodGenerator.get().compileMethod(
                  "com.amir.hotspot.GeneratedGRAMethod" +hash, "dynamicGra", accumulationFunction, resultBindings);
          this.accumulationFunction = accumulationFunction;
          this.resultBindings = resultBindings;
      }
  
      @Override
      public WorkDataValue invokeCompiled(final Instance onInst,
                                          final ExecutionParms parm,
                                          final WorkDataDefinition returntype,
                                          final TaskContext context) {
          try {
              return (WorkDataValue) this.generatedClazz
                      .getMethod("dynamicGra",
                              Instance.class,
                              ExecutionParms.class,
                              WorkDataDefinition.class,
                              TaskContext.class)
                      .invoke(null, onInst, parm, returntype, this.accumulationFunction, this.resultBindings, context);
          } catch(Exception e) {
              throw new ExecuteCompiledMethodException(this.toString(), e);
          }
      }
  
  }
  </code></pre>