private static DefineClassStrategy usingMethodHandles() throws Exception {
        Class<?> lookupClass = Class.forName("java.lang.invoke.MethodHandles$Lookup", false, null);
        Class<?> methodHandlesClass = Class.forName("java.lang.invoke.MethodHandles", false, null);

        Method lookupMethod = methodHandlesClass.getMethod("lookup");
        Method privateLookupInMethod = methodHandlesClass.getMethod("privateLookupIn", Class.class, lookupClass);
        Method defineClassMethod = lookupClass.getMethod("defineClass", byte[].class);

        return new UsingMethodHandles(lookupMethod, privateLookupInMethod, defineClassMethod);
    }
Should be available from JDK 1.9 and later
@return a strategy for calling defineClass
@throws Exception if anything goes wrong
jctools-channels/src/main/java/org/jctools/channels/proxy/DefineClassHelper.java