@Override public void setCallSiteTarget() { // targetTypes String, Enum and Class are handled // by the compiler already // Boolean / boolean handleBoolean(); handleNullWithoutBoolean(); // !! from here on args[0] is always not null !! handleInstanceCase(); // targetType is abstract Collection fitting for HashSet or ArrayList // and object is Collection or array handleCollections(); handleSAM(); // will handle : // * collection case where argument is an array // * array transformation (staticTargetType.isArray()) // * constructor invocation // * final GroovyCastException castToTypeFallBack(); if (!handle.type().equals(callSite.type())) castAndSetGuards(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Signature signature = (Signature) o; if (!methodType.equals(signature.methodType)) return false; return Arrays.equals(argNames, signature.argNames); }
private static MethodHandle checkHandle(final MethodHandle handle, final String handleKind) { if (handle != null) { final MethodType objectObjectType = MethodType.methodType(Object.class, Object.class); if (!handle.type().equals(objectObjectType)) { throw new IllegalArgumentException("Method type for " + handleKind + " must be " + objectObjectType); } } return handle; }
private void checkStarOverrideType(String name, FunctionReference target) { if ("*".equals(name) && !target.type().equals(genericMethodType(3))) { throw new AdapterDefinitionProblem("A * override must be of type (Object superHandle, Object methodName, Object args)Object: " + target); } }
/** * Join this binder to an existing one by applying its transformations after * this one. * * @param other the Binder containing the set of transformations to append * @return a new Binder combining this Binder with the target Binder */ public Binder to(Binder other) { assert type().equals(other.start); Binder newBinder = new Binder(this); for (ListIterator<Transform> iter = other.transforms.listIterator(other.transforms.size()); iter.hasPrevious(); ) { Transform t = iter.previous(); newBinder.add(t); } return newBinder; }
private void checkStarImplementationType(String name, FunctionReference target) { if ("*".equals(name) && !target.type().equals(genericMethodType(2))) { throw new AdapterDefinitionProblem("A * implementation must be of type (Object methodName, Object args)Object: " + target); } }
private static void assertType(MethodHandle mh, MethodType type) { if(!mh.type().equals(type)) { throw new WrongMethodTypeException("Expected type: " + type + " actual type: " + mh.type()); } } }
private static void assertType(final MethodHandle mh, final MethodType type) { if(!mh.type().equals(type)) { throw new WrongMethodTypeException("Expected type: " + type + " actual type: " + mh.type()); } } }
/** * Returns true if this call site descriptor is equal to the passed call site descriptor. * @param csd the other call site descriptor. * @return true if they are equal. */ public boolean equals(final CallSiteDescriptor csd) { if(csd == null) { return false; } if(csd == this) { return true; } final int ntc = getNameTokenCount(); if(ntc != csd.getNameTokenCount()) { return false; } for(int i = ntc; i-- > 0;) { // Reverse order as variability is higher at the end if(!Objects.equals(getNameToken(i), csd.getNameToken(i))) { return false; } } if(!getMethodType().equals(csd.getMethodType())) { return false; } return lookupsEqual(getLookup(), csd.getLookup()); }
/** * Returns true if this call site descriptor is equal to the passed call site descriptor. * @param csd the other call site descriptor. * @return true if they are equal. */ public boolean equals(CallSiteDescriptor csd) { if(csd == null) { return false; } if(csd == this) { return true; } final int ntc = getNameTokenCount(); if(ntc != csd.getNameTokenCount()) { return false; } for(int i = ntc; i-- > 0;) { // Reverse order as variability is higher at the end if(!Objects.equals(getNameToken(i), csd.getNameToken(i))) { return false; } } if(!getMethodType().equals(csd.getMethodType())) { return false; } return lookupsEqual(getLookup(), csd.getLookup()); }
final MethodHandle nextComponentInvocation = nextComponent.getGuardedInvocation().getInvocation(); assert nextComponentInvocation.type().equals(type);
assert nextComponentInvocation.type().changeReturnType(type.returnType()).equals(type);