< prev index next >

src/jdk/nashorn/internal/runtime/ScriptObject.java

Print this page
rev 1392 : 8087136: regression: apply on $EXEC fails with ClassCastException
Reviewed-by: hannesw, lagergren

*** 2578,2599 **** return methodHandle; } final int parameterCount = methodType.parameterCount(); final int callCount = callType.parameterCount(); - final int pdiff = callCount - parameterCount + 1; final boolean isCalleeVarArg = parameterCount > 0 && methodType.parameterType(parameterCount - 1).isArray(); final boolean isCallerVarArg = callerVarArg != null ? callerVarArg : callCount > 0 && callType.parameterType(callCount - 1).isArray(); ! // A value of pdiff < 0 means that there are additional normal arguments in the callee that must not be consumed ! // by the vararg collector. No vararg collector is required in that case, and no varargs are passed. ! if (isCalleeVarArg && pdiff >= 0) { return isCallerVarArg ? methodHandle : ! MH.asCollector(methodHandle, Object[].class, pdiff); } if (isCallerVarArg) { return adaptHandleToVarArgCallSite(methodHandle, callCount); } --- 2578,2596 ---- return methodHandle; } final int parameterCount = methodType.parameterCount(); final int callCount = callType.parameterCount(); final boolean isCalleeVarArg = parameterCount > 0 && methodType.parameterType(parameterCount - 1).isArray(); final boolean isCallerVarArg = callerVarArg != null ? callerVarArg : callCount > 0 && callType.parameterType(callCount - 1).isArray(); ! if (isCalleeVarArg) { return isCallerVarArg ? methodHandle : ! MH.asCollector(methodHandle, Object[].class, callCount - parameterCount + 1); } if (isCallerVarArg) { return adaptHandleToVarArgCallSite(methodHandle, callCount); }
< prev index next >