You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a COM method returns a VARIANT and the Java return type is a primitive type, the conversion function Variant.convertTo falls back to converting based on the type of the variant, and not the Java type.
This is because all the Java types in the SetterEntry mapping are the boxed types, and the type that is tested against is the primitive type.
Falling back to the VTTYPE is usually fine as the variant should be the type expected. This is not always the case though, and so com4j should handle coercing the type into the expected type. For example, many Excel COM methods that are described in the typelib as returning VT_I4 (long) actually return VT_R8 (double). These methods cause a problem when called through com4j as variant gets converted to the type matching the variant which doesn't match the expected return type.
To fix this, when converting to the java return type the target type should be the boxed type.
The text was updated successfully, but these errors were encountered:
When a COM method returns a VARIANT and the Java return type is a primitive type, the conversion function Variant.convertTo falls back to converting based on the type of the variant, and not the Java type.
This is because all the Java types in the SetterEntry mapping are the boxed types, and the type that is tested against is the primitive type.
Falling back to the VTTYPE is usually fine as the variant should be the type expected. This is not always the case though, and so com4j should handle coercing the type into the expected type. For example, many Excel COM methods that are described in the typelib as returning VT_I4 (long) actually return VT_R8 (double). These methods cause a problem when called through com4j as variant gets converted to the type matching the variant which doesn't match the expected return type.
To fix this, when converting to the java return type the target type should be the boxed type.
The text was updated successfully, but these errors were encountered: