FIX: java.lang.ClassCastException on Variant Objects (260280)
The information in this article applies to:
- Microsoft virtual machine
This article was previously published under Q260280 SYMPTOMS
A java.lang.ClassCastException is generated when you use a COM object obtained from a com.ms.com.Variant.toObject() or Variant.toDispatch(). Specifically, the Variant, generated through Variant.clone() or Variant.cloneIndirect(), contains a reference to a COM proxy (COM interface pointer marshaled to another thread).
CAUSE
The Microsoft virtual machine's implementation of Variant.clone() and Variant.cloneIndirect() invokes the Win32 VariantCopy and VariantCopyInd functions, respectively, on the caller's thread instead of the Variant's home thread. If the underlying object stored in the Variant is a COM proxy, an attempt to perform a QueryInterface to the COM interface causes a COM error, which is represented as a java.lang.ClassCastException in Java.
An example that demonstrates this problem is included in the "More Information" section.
RESOLUTION
A workaround for this problem is to use ComLib.executeOnContext() to call Variant.clone() or Variant.cloneIndirect() on the Variant's home thread by passing the target Variant as the first parameter to ComLib.executeOnContext().
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This problem was corrected in Windows 2000 Service Pack 1.
REFERENCESFor additional information about the latest service pack for Windows 2000, click the article number below
to view the article in the Microsoft Knowledge Base:
260910 How to Obtain the Latest Windows 2000 Service Pack
For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:
Modification Type: | Major | Last Reviewed: | 6/14/2006 |
---|
Keywords: | kbBug kbfix kbJava kbJavaVM33xxfix kbWin2000sp1Fix KB260280 |
---|
|