Fields in Java-Callable Data Wrappers (JCDWs) and parameters in vtable interfaces of type TD_CUSTOM, TD_CUSTOMBYREF, or TD_CUSTOMBYVAL are custom marshaled. Custom marshaling means that code external to the Microsoft VM converts Java values and objects so they are understood by COM methods, and vice versa. Associated with custom marshaled fields and parameters is a hook class.
Note When passing an array of JCDW's between COM/Microsoft® Win32® APIs and Java, in either direction, if the JCDW contains complex types such as Strings, then these complex types may not be properly propagated to memory that is not garbage collected. For normal JCDW parameters, the marshaling engine always attempts to propagate structs, but this code is missing from the case of marshaling arrays.
This section includes the following topics:
Creating a Custom Class Object describes how to extend the Microsoft VM's default class object (class factory).
Creating a Custom Interface discusses COM interfaces in connection with the kind of marshaling support you choose.
Custom Marshaling Structures and Parameters describes using the @com.parameters and @com.structmap compiler directives and other issues related to custom marshaling structures and parameters.
Example of Custom Marshaling demonstrates how to marshal a simple structure type between a COM type library and Java.
Hook Class Overview introduces how the Microsoft VM uses JTYPEs and ETYPEs to call the appropriate hook method.
Hook Class Examples conclude this section.
Because jactivex cannot automatically create type mappings that work for user-defined types, Jactivex needs information on how to generate the Java type declarations. Do this by creating a Java type library information file (.jnf) file, which describes your custom data types. Passing the .jnf to Jactivex creates the COM library class header file.
The .jnf file has the following format:
[Custom] <TypeLib Type>= <Java Type>, <Hook Class>
Where:
This section explains how to implement custom marshaling of user-defined types between Java and COM. This involves writing a hook class to do the marshaling, and using jactivex /javatlb to create a Java type library information file (.jnf). This file describes the custom interface.
You write a hook class for each user-defined type you want to marshal from COM to Java. The class contains the code that actually does the marshaling and translates the COM type to a Java type and the Java type to a COM type. Much of this discussion addresses what a hook class is and how to author one.
Jactivex creates Java libraries from existing COM interfaces. COM interfaces are based on type libraries, so a Java type library is a file that maps user-defined types in existing COM type libraries to hook classes.