|
Java Object Categories
In this model, all Java objects fall into one of the following categories.
- Pure Java objects. These objects are allocated on the garbage-collected heap, and garbage collection controls their lifetime. Optionally, pure Java objects can have an associated proxy known as the COM-callable wrapper (CCW), which is a thread-safe, VM-created COM object that exports vtable or IDispatch interfaces. These proxies are implemented by the run time and marshal to methods on the Java object. As long as there is one outstanding AddRef method on the CCW, the CCW maintains a "root pointer" to the actual Java object to prevent it from being reclaimed.
- Java-callable wrappers (JCWs). JCWs are stateless "wrapper" objects that represent a single COM object. JCWs can either be instances of special classes generated from typelibs, or be automatically made instances of the com.ms.com.CUnknown class. Unlike normal classes, which implement a fixed set of interfaces declared by the object's class, JCWs can be cast to any interface at will, provided that the underlying COM object accepts the QueryInterface of the interface's underlying IID (stored in attributes in the interface's .class file.) JCWs always inherit from java.lang.Object. They currently cannot derive from any other class.
- Java-callable data wrappers (JCDWs). These are proxies for external data structures (structs, unions, and arrays.) In this case, the external data structure is passed in from native code through a COM interface. To avoid copying data, the proxy will maintain an address of the actual data, and the proxy's fields will be mapped by means of attributes to offsets within the data structure. A set of application programming interfaces (APIs) will allow byte-level traversal of the memory (as a fallback for very difficult structures such as DVTARGETDEVICE). Garbage collection controls a proxy's lifetime. Since no universal protocol exists for tracking an external data structure's lifetime, the burden is on the developer not to use the proxy after the underlying data structure has been released.
|