use of org.graalvm.nativebridge.BinaryOutput.CCharPointerBinaryOutput in project graal by oracle.
the class JNINativeMarshallerAdapter method marshall.
@Override
public JObject marshall(JNIEnv env, T object) {
if (object == null) {
return WordFactory.nullPointer();
}
int bufSize = BUFFER_SIZE;
CCharPointer buffer = StackValue.get(bufSize);
try (CCharPointerBinaryOutput out = BinaryOutput.create(buffer, bufSize, false)) {
binaryMarshaller.write(out, object);
int len = out.getPosition();
JByteArray binaryData = JNIUtil.NewByteArray(env, len);
JNIUtil.SetByteArrayRegion(env, binaryData, 0, len, out.getAddress());
return binaryData;
} catch (IOException e) {
throw new AssertionError(e.getMessage(), e);
}
}
Aggregations