private static boolean isSAM(Class<?> c) { return CachedSAMClass.getSAMMethod(c) !=null; }
private void handleSAM() { if (handle!=null) return; if (!(args[0] instanceof Closure)) return; Method m = CachedSAMClass.getSAMMethod(staticTargetType); if (m==null) return; //TODO: optimize: add guard based on type Closure handle = MethodHandles.insertArguments(SAM_CONVERSION, 1, m, staticTargetType); }
public CachedSAMClass(Class klazz, ClassInfo classInfo) { super(klazz, classInfo); method = getSAMMethod(klazz); if (method==null) throw new GroovyBugError("assigned method should not have been null!"); }
if (clazz.isInterface() && !(clazz.isInstance(cl))) { if (Traits.isTrait(clazz)) { Method samMethod = CachedSAMClass.getSAMMethod(clazz); if (samMethod!=null) { Map impl = Collections.singletonMap(samMethod.getName(),cl);
Method method = CachedSAMClass.getSAMMethod(parameter); if (method == null) return null;
private static Object continueCastOnSAM(Object object, Class type) { if (object instanceof Closure) { Method m = CachedSAMClass.getSAMMethod(type); if (m != null) { return CachedSAMClass.coerceToSAM((Closure) object, m, type);