static void tryMetafactory( boolean correct, MethodHandle mh, Class<?>[] captured, MethodType instMT, MethodType samMT) { try { LambdaMetafactory.metafactory( lookup, "run", methodType(I.class, captured), samMT, mh, instMT); if (!correct) { throw new AssertionError( "Uncaught linkage error:" + " impl=" + mh + ", captured=" + Arrays.toString(captured) + ", inst=" + instMT + ", sam=" + samMT); } } catch (LambdaConversionException e) { if (correct) { throw new AssertionError( "Unexpected linkage error:" + " e=" + e + ", impl=" + mh + ", captured=" + Arrays.toString(captured) + ", inst=" + instMT + ", sam=" + samMT); } } }