title: LambdaMetafactory to access class on a different ClassLoader
body: <p>I have this code which works fine:</p>
  
  <pre><code>Method getterMethod = Person.class.getDeclaredMethod("getName");
  
  MethodHandles.Lookup lookup = MethodHandles.publicLookup();
  Class&lt;?&gt; declaringClass = getterMethod.getDeclaringClass();
  Class&lt;?&gt; returnType = getterMethod.getReturnType();
  CallSite getterSite = LambdaMetafactory.metafactory(lookup,
      "apply",
      MethodType.methodType(Function.class),
      MethodType.methodType(Object.class, Object.class),
      lookup.findVirtual(declaringClass, getterMethod.getName(), MethodType.methodType(returnType)),
      MethodType.methodType(propertyType, declaringClass));
  
  Function getterFunction = (Function) getterSite.getTarget().invokeExact();
  </code></pre>
  
  <p>But if the <code>getterMethod</code> is a method from a class loaded from a different ClassLoader, it throws:</p>
  
  <pre><code>Caused by: java.lang.invoke.LambdaConversionException: Invalid caller: java.lang.Object
      at java.lang.invoke.AbstractValidatingLambdaMetafactory.&lt;init&gt;(AbstractValidatingLambdaMetafactory.java:118)
      at java.lang.invoke.InnerClassLambdaMetafactory.&lt;init&gt;(InnerClassLambdaMetafactory.java:155)
      at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:299)
  </code></pre>
  
  <p>How do I pass my <code>ClassLoader</code> instance to the <code>LambdaMetafactory</code>?</p>