Overview of COM Attributes for Java Class Files |
|
|
 Previous |
 Virtual Machine |
 Next |
Java Object Categories
In this model, all Java objects fall into one of these categories:
- Pure Java objects. These objects are allocated on the garbage-collected heap and their lifetime is controlled by garbage collection. Optionally, pure Java objects can have an associated proxy known as the CCW (COM-callable wrapper), 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 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 of data, the proxy will maintain a pointer to the actual data, and the fields of the proxy will be mapped via attributes to offsets within the data structure. There will also be a set of APIs that will allow byte-level traversal of the memory (as a fallback for very difficult structures such as DVTARGETDEVICE) The lifetime of a proxy is controlled by garbage collection. Since there is no universal protocol for tracking the lifetime of an external data structure, the burden is on the developer not to use the proxy after the underlying data structure has been released.