@Test public void usageExample() { ProcessFunctionInvoker<String, Long> generatedCodeThatInvokesUserCode = ByteBuddyProcessFunctionInvoker.create(specification); arguments[0].value = Long.MAX_VALUE; generatedCodeThatInvokesUserCode.invoke("does not matter", context, arguments); assertThat(context.emitted, hasItem(Long.MAX_VALUE)); }
public static <InT, OutT> ProcessFunctionInvoker<InT, OutT> create(StreamingLedgerSpec<InT, OutT> spec) { final ClassLoader userClassLoader = classLoader(spec); final Class<?> generatedClass = CACHE.findOrInsert(userClassLoader, spec, () -> generateAndLoadClass(spec)); try { return createInstance(generatedClass, spec); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { throw new RuntimeException("Unable to create a new instance for " + spec.processFunction, e); } }
ByteBuddyProcessFunctionInvoker { public static <InT, OutT> ProcessFunctionInvoker<InT, OutT> create(StreamingLedgerSpec<InT, OutT> spec) { final ClassLoader userClassLoader = classLoader(spec); final Class<?> generatedClass = CACHE.findOrInsert(userClassLoader, spec, () -> generateAndLoadClass(spec)); try { return createInstance(generatedClass, spec); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { throw new RuntimeException("Unable to create a new instance for " + spec.processFunction, e); } } }
ByteBuddyProcessFunctionInvoker { public static <InT, OutT> ProcessFunctionInvoker<InT, OutT> create(StreamingLedgerSpec<InT, OutT> spec) { final ClassLoader userClassLoader = classLoader(spec); final Class<?> generatedClass = CACHE.findOrInsert(userClassLoader, spec, () -> generateAndLoadClass(spec)); try { return createInstance(generatedClass, spec); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { throw new RuntimeException("Unable to create a new instance for " + spec.processFunction, e); } }  }
ByteBuddyProcessFunctionInvoker { public static <InT, OutT> ProcessFunctionInvoker<InT, OutT> create(StreamingLedgerSpec<InT, OutT> spec) { final ClassLoader userClassLoader = classLoader(spec); final Class<?> generatedClass = CACHE.findOrInsert(userClassLoader, spec, () -> generateAndLoadClass(spec)); try { return createInstance(generatedClass, spec); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { throw new RuntimeException("Unable to create a new instance for " + spec.processFunction, e); } }  static ProcessFunctionInvoker<InT, OutT> create(StreamingLedgerSpec<InT, OutT> spec); }
ByteBuddyProcessFunctionInvoker { public static <InT, OutT> ProcessFunctionInvoker<InT, OutT> create(StreamingLedgerSpec<InT, OutT> spec) { final ClassLoader userClassLoader = classLoader(spec); final Class<?> generatedClass = CACHE.findOrInsert(userClassLoader, spec, () -> generateAndLoadClass(spec)); try { return createInstance(generatedClass, spec); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { throw new RuntimeException("Unable to create a new instance for " + spec.processFunction, e); } }  static ProcessFunctionInvoker<InT, OutT> create(StreamingLedgerSpec<InT, OutT> spec);  }