Skip to content

Commit

Permalink
Fix adaptation from Slice to Object stack type
Browse files Browse the repository at this point in the history
  • Loading branch information
dain committed Aug 5, 2020
1 parent 94f2ae2 commit 8131d34
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ private MethodHandle adaptParameter(

// caller will pass boolean true in the next argument for SQL null
if (expectedArgumentConvention == BLOCK_POSITION) {
MethodHandle getBlockValue = getBlockValue(argumentType);
MethodHandle getBlockValue = getBlockValue(argumentType, methodHandle.type().parameterType(parameterIndex));

if (actualArgumentConvention == NEVER_NULL) {
if (nullAdaptationPolicy == UNDEFINED_VALUE_FOR_NULL) {
Expand Down Expand Up @@ -487,7 +487,7 @@ private MethodHandle adaptParameter(
throw new IllegalArgumentException("Unsupported expected argument convention: " + expectedArgumentConvention);
}

private static MethodHandle getBlockValue(Type argumentType)
private static MethodHandle getBlockValue(Type argumentType, Class<?> expectedType)
{
Class<?> methodArgumentType = argumentType.getJavaType();
String getterName;
Expand All @@ -511,7 +511,7 @@ else if (methodArgumentType == Slice.class) {
try {
MethodHandle getValue = lookup().findVirtual(Type.class, getterName, methodType(methodArgumentType, Block.class, int.class))
.bindTo(argumentType);
return explicitCastArguments(getValue, getValue.type().changeReturnType(argumentType.getJavaType()));
return explicitCastArguments(getValue, getValue.type().changeReturnType(expectedType));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
Expand Down
Loading

0 comments on commit 8131d34

Please sign in to comment.