Packages
 In this topic

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.com   Previous This
Package
Next

 


Class ComLib

public class ComLib
{
  // Methods
  public native static void declareMessagePumpThread();
  public static native boolean isEqualUnknown(Object o1, Object o2);
  public native static int jcdwClassOffsetOf(Class cls,
        String fieldName);
  public native static int jcdwClassSizeOf(Class cls);
  public native static int jcdwOffsetOf(Object jcdw,
        String fieldName);
  public native static int jcdwSizeOf(Object jcdw);
  public static boolean ownsCleanup(Object structObj);
  public native static Object makeProxyRef(Object o);
  public static native Object ptrToStruct(Class structClass,
        int ptr);
  public native static void release(Object o);
  protected static native void setDataWrapperSize(
        Object DataWrapper, int cb);
  public native static boolean supportsInterface(Object pComObject,
        _Guid iid);
  public static native void threadStartMTA(Thread thd);
}

This class contains routines that are used during Java Component Object Model (COM) integration. All ComLib methods are static; therefore, you can use this class without instantiating it.

Methods

declareMessagePumpThread

public native static void declareMessagePumpThread();

Enables apartment model hosting.

Return Value:

No return value.

isEqualUnknown

public static native boolean isEqualUnknown(Object o1, Object o2);

Compares the COM identity of two Java objects. If the two objects have equal IUnknown* pointers, they have the same COM identity.

Return Value:

Returns true if the two objects have the same COM identity; otherwise, returns false.

ParameterDescription
o1 The first object to be compared.
o2 The second object to be compared.

jcdwClassOffsetOf

public native static int jcdwClassOffsetOf(Class cls, String fieldName);

Retrieves the offset of a COM data structure that represents an instance of a Java proxy class. The offset is measured in bytes.

Return Value:

Returns the offset of a COM data structure, measured in bytes.

ParameterDescription
cls The class object for a Java proxy to a COM data structure.
fieldName The name of the COM-mapped field.

jcdwClassSizeOf

public native static int jcdwClassSizeOf(Class cls);

Retrieves the size (measured in bytes) of a COM data structure that represents instances of the class.

Return Value:

Returns the size of a COM data structure, measured in bytes.

ParameterDescription
cls The class object for a Java proxy to a COM data structure.

jcdwOffsetOf

public native static int jcdwOffsetOf(Object jcdw, String fieldName);

Retrieves the offset of a COM data structure (measured in bytes) that is represented by a Java proxy.

Return Value:

Returns the COM data structure offset, measured in bytes.

ParameterDescription
jcdw The Java proxy to a data structure.
fieldName The name of the COM-mapped field.

jcdwSizeOf

public native static int jcdwSizeOf(Object jcdw);

Retrieves the size of a COM data structure (measured in bytes) that is represented by a Java proxy.

Return Value:

Returns the size of a COM data structure, measured in bytes.

ParameterDescription
jcdw The Java proxy to a data structure.

ownsCleanup

public static boolean ownsCleanup(Object structObj);

Determines whether Java is responsible for doing cleanup tasks for the COM object.

Return Value:

Returns true if the object is owned by Java; otherwise, returns false.

ParameterDescription
structObj The COM object that is being checked.

makeProxyRef

public native static Object makeProxyRef(Object o);

Increments the reference count on a COM object.

Return Value:

Returns a Java callable wrapper that holds a reference to the COM object. When the returned JCW is garbage collected, the reference is dropped.

ParameterDescription
o Any Java object that can be mapped to a COM object.

ptrToStruct

public static native Object ptrToStruct(Class structClass, int ptr);

Maps a raw pointer onto a structure. This method simulates a C-style cast of an arbitrary pointer to a structure.

Return Value:

Returns an instance of structClass.

ParameterDescription
structClass The class declared using @dll.struct.
ptr The raw pointer that is mapped.

release

public native static void release(Object o);

Forces Java to release all outstanding reference counts on a native COM object. After releasing the reference counts, any attempts to use the COM object through this Java proxy results in an UnsatisfiedLinkError. If the specified object does not wrap a native COM object, this method quietly succeeds but does nothing.

Return Value:

No return value.

ParameterDescription
o The Java proxy of a native COM object.

Remarks:

If the Java proxy wraps a non–thread-safe native COM object that was created on another thread, the actual release of the object can occur after the release method has returned.

setDataWrapperSize

protected static native void setDataWrapperSize(Object DataWrapper, int cb);

Allocates and binds memory to an existing data wrapper.

Return Value:

No return value.

ParameterDescription
DataWrapper The wrapper that memory is allocated and bound to.
cb The memory (measured in bytes) that is bound to the data wrapper.

supportsInterface

public native static boolean supportsInterface(Object pComObject,
        _Guid iid);

Determines whether a COM object supports a particular interface by using that object's QueryInterface method. The interface is not returned because Java interfaces exist only at compile time and are not distinguishable from the main object at runtime.

Return Value:

Returns true if the interface is supported; otherwise, returns false.

ParameterDescription
pComObject Any Java object that can be mapped to a COM object.
iid The identifier of the interface to query for.

threadStartMTA

public static native void threadStartMTA(Thread thd);

Initializes a thread without initializing COM. This means that (by default) the thread will be in a COM multi-threaded apartment. This method is similar to the Thread.start method, but Thread.start initializes the thread as a separate single-threaded COM apartment.

Return Value:

No return value.

ParameterDescription
thd The Thread to start.

Exceptions:

IllegalThreadStateException if the thread was already started.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.