Lambdas { public static LambdaInfo reflect(Object lambda) { Objects.requireNonNull(lambda); SerializedLambda serializedLambda = getSerializedLambda(lambda); Method functionalMethod; try { functionalMethod = getMethod(lambda.getClass(), serializedLambda.getFunctionalInterfaceMethodName()); functionalMethod.setAccessible(true); } catch (ClassNotFoundException | NoSuchMethodException e) { throw new RuntimeException("Unable to getFunctionalMethod", e); } Method implementationMethod; try { implementationMethod = getImplementationMethod(serializedLambda); } catch (ClassNotFoundException | NoSuchMethodException e) { throw new RuntimeException("Unable to getImplementationMethod", e); } Kind kind; int implMethodKind = serializedLambda.getImplMethodKind(); if (implMethodKind == 6) { if (serializedLambda.getImplMethodName().startsWith("lambda$")) { kind = Kind.ANONYMOUS_METHOD_REFERENCE; } else { kind = Kind.STATIC_METHOD_REFERENCE; } } else { if (serializedLambda.getCapturedArgCount() > 0) { kind = Kind.SPECIFIC_INSTANCE_METHOD_REFERENCE; } else { kind = Kind.ANY_INSTANCE_METHOD_REFERENCE; } } return new LambdaInfo(lambda, kind, serializedLambda, functionalMethod, implementationMethod); }  static LambdaInfo reflect(Object lambda); static SerializedLambda getSerializedLambda(Object lambda); static Method getFunctionalMethod(SerializedLambda serializedLambda); static Method getImplementationMethod(SerializedLambda serializedLambda); static Method getMethod(String className, String methodName); static Method getMethod(Class<?> clazz, String methodName);  }
@Test public void anonymousClassReference() throws Exception { @SuppressWarnings("Convert2Lambda") ControllerMethod1<Context> lambda = new ControllerMethod1<Context>() { @Override public Result apply(Context a) { return Results.html().renderRaw("".getBytes(StandardCharsets.UTF_8)); } }; try { LambdaInfo lambdaInfo = Lambdas.reflect(lambda); fail(); } catch (IllegalArgumentException e) { } }