JiGlue COM Bridge Data Types

This topic describes JiGlue COM Bridge data types, including:

COM Bridge Data Type Conversions

The JiGlue COM Bridge supports the following Java to COM data type conversions:

Java data type

COM data type

boolean (java.lang.Boolean)

Boolean (VT_I1)

char (java.lang.Char) 2-byte unsigned (VT_UI2)

integer (java.lang.Integer)

4-byte signed integer (VT_I4)

short (java.lang.Short) 2-byte signed integer (VT_I2)
long (java.lang.Long) 2-byte signed integer (VT_I4)

float (java.lang.Float)

Float (VT_R4)

double (java.lang.Double) Double (VT_R8)

java.lang.String

BSTR (VT_BSTR)

java.util.Date Date (VT_DATE)

Other Java object

IDispatch (VT_DISPATCH)

COM Bridge Data Types Guidelines

However, if a Java method returns an object other than the java.lang.* (see below), the Set statement is needed.

Example 2:

Dim myDate As Variant
Dim mySimpleDate As Variant
Set mySimpleDate = JiGlue.newInstance("java.text.SimpleDateFormat")
myDate = mySimpleDate.parse("09/12/2001 11:59 am")

In the examples shown above, mySimpleDate was declared as both Object and Variant (in the different examples); in both cases, the object reference was assigned by using Set. Notice that in both cases myDate was declared as Variant without using the Set statement. The reason this works as coded, is because SimpleDateFormat.parse returns java.util.Date which is mapped to Visual Basic's Date type (which is non-object — see table above). As previously indicated, if a Java method returns an object other than the java.lang.* (as indicated above), the Set statement is needed. Note that the Jiglue.newInstance method can only instantiate an object whose class has a default constructor (that is, without any argument).