com.jinvoke
Annotation Type ByVal


@Retention(value=RUNTIME)
@Target(value=PARAMETER)
public @interface ByVal

Indicates that struct method parameter be marshaled by value.

The @ByVal annotation is to be applied to struct parameters of a native method (annotated with @NativeImport). When this annotation is present, the struct is marshaled by value to the native code. In the absence of this annotation, the struct is marshaled by reference. i.e. a pointer to that struct is sent to native code.

Example: If the native method accepts a pointer to a struct, the corresponding J/Invoke method declaration uses the struct as the method parameter:

C function prototype:
    void structByRefTest(DSCADSETTINGS * adsettings);

J/Invoke method signature (Java):
        public static native void structByRefTest(DSCADSETTINGS adsettings);

If the native method accepts a struct by value, the corresponding J/Invoke method declaration uses the struct as the method parameter, annotated using the @ByVal annotation:

C function prototype:
    void structByValTest(DSCADSETTINGS adsettings);

J/Invoke method signature (Java):
        public static native void structByValTest(@ByVal DSCADSETTINGS adsettings);
This annotation only applies to struct parameters of native methods.