@Retention(value=RUNTIME) @Target(value={PARAMETER,METHOD,ANNOTATION_TYPE}) public @interface Out
When a java object is passed to a native function as a pointer
(for example Pointer
, Struct
, ByteBuffer
),
then a temporary native memory block is allocated, the java data is copied to
the temporary memory and the address of the temporary memory is passed to the function.
After the function returns, the java data is automatically updated from the
contents of the native memory.
As this extra copying can be expensive, for native functions which only
write to the passed in memory block and do not use the existing contents,
parameters can be annotated with @Out
so there is only copied OUT
from native memory to java memory after the call, and the unneccessary copy IN
from java to native memory before the call can be avoided.
Parameters with neither a @In
nor a @Out
annotation will copy both ways.
Copyright © 2017. All rights reserved.