Closed dreamlike-ocean closed 9 months ago
if (returnPointer) { //先调整返回值类型对应的memorySegment长度 methodHandle = MethodHandles.filterReturnValue( methodHandle, MethodHandles.insertArguments( NativeGeneratorHelper.REINTERPRET_MH, 1, returnLayout.byteSize() ) ); //绑定当前的StructProxyGenerator //绑定的结果是 (MemorySegment) -> ${returnType} MethodHandle returnEnhance = StructProxyGenerator.ENHANCE_MH .asType(StructProxyGenerator.ENHANCE_MH.type().changeReturnType(method.getReturnType())) .bindTo(structProxyGenerator) .bindTo(method.getReturnType()); //来把MemorySegment返回值转换为java bean methodHandle = MethodHandles.filterReturnValue( methodHandle, returnEnhance ); }
NativeGeneratorHelper.REINTERPRET_MH, 不应该直接REINTERPRET而是读出来地址值转化为MemorySegment 之后再REINTERPRET最后作为底层MemorySegment 绑定到proxy上
跟着 #32 一起修复
NativeGeneratorHelper.REINTERPRET_MH, 不应该直接REINTERPRET而是读出来地址值转化为MemorySegment 之后再REINTERPRET最后作为底层MemorySegment 绑定到proxy上