Supported COM Data Types

J-Integra® supports the full range of COM Oleautomation types, and these COM types map to existing Java types. For example, the COM VARIANT type maps to the java.lang.Object type. And a VARIANT containing an array maps to a Java array.


Contents


How COM IDL Types Map to Java, VB, and VC++

The following table shows all the supported COM IDL types (which can be seen by viewing a COM component's type library), and their associated mappings to Java, VB, and Visual C++.

Passing COM Arrays to Java

The default behaviour of the com2java tool is to generate Java proxies which only support one-dimensional COM arrays (as shown in the table below). However, the com2java option -- "Generate Arrays as Objects" -- can be used if you need to pass multi-dimensional COM arrays.

Multi-dimensional COM arrays can also be passed within VARIANTs, in which case you do not need to use the "Generate Arrays as Objects" option. Please see the next section on COM VARIANTs for details.

IDL Data Type

Java (i.e. the com2java-generated type)

VB [in]* and [out]* not supported

VC++

[in] VARIANT_BOOL or [out, retval] VARIANT_BOOL*

boolean

Boolean

boolean

[in] VARIANT_BOOL*

boolean Use com2java option: Don't treat [in]* parameters as arrays

Boolean

boolean

[in, out] VARIANT_BOOL* or [out] VARIANT_BOOL*

boolean[] single element array

Boolean

boolean

[in] unsigned char or [out, retval] unsigned char*

byte

Byte

unsigned char

[in] unsigned char*

byte Use com2java option: Don't treat [in]* parameters as arrays

Byte

unsigned char

[in, out] unsigned char* or [out] unsigned char*

byte[] single element array

Byte

unsigned char

[in] double or [out, retval] double*

double

Double

double

[in] double*

double Use com2java option: Don't treat [in]* parameters as arrays

Double

double

[in, out] double* or [out] double*

double[] single element array

Double

double

[in] float or [out, retval] float*

float

Single

float

[in] float*

float Use com2java option: Don't treat [in]* parameters as arrays

Single

float

[in, out] float* or [out] float*

float[] single element array

Single

float

[in] long or [out, retval] long*

int

Long

long

[in] long*

int Use com2java option: Don't treat [in]* parameters as arrays

Long

long

[in, out] long* or [out] long*

int[] single element array

Long

long

[in] short or [out, retval] short*

short

Integer

short

[in] short*

short Use com2java option: Don't treat [in]* parameters as arrays

Integer

short

[in, out] short* or [out] short*

short[] single element array

Integer

short

[in] BSTR or [out, retval] BSTR*

java.lang.String

String

BSTR

[in] BSTR*

java.lang.String Use com2java option: Don't treat [in]* parameters as arrays

String

BSTR

[in, out] BSTR* or [out] BSTR*

java.lang.String[] single element array

String

BSTR

[in] CURRENCY or [out, retval] CURRENCY*

long

Currency

CURRENCY

[in] CURRENCY*

long Use com2java option: Don't treat [in]* parameters as arrays

Currency

CURRENCY

[in, out] CURRENCY* or [out] CURRENCY*

long[] single element array

Currency

CURRENCY

[in] DATE or [out, retval] DATE*

java.util.Date

Date

DATE

[in] DATE*

java.util.Date Use com2java option: Don't treat [in]* parameters as arrays

Date

DATE

[in, out] DATE* or [out] DATE*

java.util.Date[] single element array

Date

DATE

[in] VARIANT or [out, retval] VARIANT*

java.lang.Object

Variant

VARIANT

[in] VARIANT*

java.lang.Object

Variant

VARIANT

[in, out] VARIANT* or [out] VARIANT*

java.lang.Object[] single element array

Variant

VARIANT

[in] LPDISPATCH or [out, retval] LPDISPATCH*

java.lang.Object

Object

LPDISPATCH

[in] LPDISPATCH*

java.lang.Object Use com2java option: Don't treat [in]* parameters as arrays

Object

LPDISPATCH

[in, out] LPDISPATCH* or [out] LPDISPATCH*

java.lang.Object[] single element array

Object

LPDISPATCH

[in] LPUNKNOWN or [out, retval] LPUNKNOWN*

java.lang.Object

Object

LPUNKNOWN

[in] LPUNKNOWN*

java.lang.Object Use com2java option: Don't treat [in]* parameters as arrays

Object

LPUNKNOWN

[in, out] LPUNKNOWN* or [out] LPUNKNOWN*

java.lang.Object[] single element array

Object

LPUNKNOWN

[in] ITypename* or [out, retval] (ITypename*)*

ITypename

ITypename

ITypename*

[in] (ITypename*)*

ITypename

ITypename

ITypename*

[in, out] (ITypename*)* or [out] (ITypename*)*

ITypename[] single element array

ITypename

ITypename*

[in] Classname* or [out, retval] (Classname*)*

Classname

Classname

Classname*

[in] (Classname*)*

Classname

Classname

Classname*

[in, out] (Classname*)* or [out] (Classname*)*

Classname[] single element array

Classname

Classname*

[in] SAFEARRAY(unsigned char) or [in] SAFEARRAY(unsigned char)* or [out, retval] SAFEARRAY(unsigned char)*

byte[]

Dim arr() As Byte

SAFEARRAY

[in, out] SAFEARRAY(unsigned char)* or [out] SAFEARRAY(unsigned char)*

byte[][] single element array containing a 1D array

Dim arr() As Byte

SAFEARRAY

[in] SAFEARRAY(VARIANT_BOOL) or [in] SAFEARRAY(VARIANT_BOOL)* or [out, retval] SAFEARRAY(VARIANT_BOOL)*

boolean[]

Dim arr() As Boolean

SAFEARRAY

[in, out] SAFEARRAY(VARIANT_BOOL)* or [out] SAFEARRAY(VARIANT_BOOL)*

boolean[][] single element array containing a 1D array

Dim arr() As Boolean

SAFEARRAY

[in] SAFEARRAY(short) or [in] SAFEARRAY(short)* or [out, retval] SAFEARRAY(short)*

short[]

Dim arr() As Integer

SAFEARRAY

[in, out] SAFEARRAY(short)* or [out] SAFEARRAY(short)*

short[][] single element array containing a 1D array

Dim arr() As Integer

SAFEARRAY

[in] SAFEARRAY(long) or [in] SAFEARRAY(long)* or [out, retval] SAFEARRAY(long)*

int[]

Dim arr() As Long

SAFEARRAY

[in, out] SAFEARRAY(long)* or [out] SAFEARRAY(long)*

int[][] single element array containing a 1D array

Dim arr() As Long

SAFEARRAY

[in] SAFEARRAY(float) or [in] SAFEARRAY(float)* or [out, retval] SAFEARRAY(float)*

float[]

Dim arr() As Single

SAFEARRAY

[in, out] SAFEARRAY(float)* or [out] SAFEARRAY(float)*

float[][] single element array containing a 1D array

Dim arr() As Single

SAFEARRAY

[in] SAFEARRAY(double) or [in] SAFEARRAY(double)* or [out, retval] SAFEARRAY(double)*

double[]

Dim arr() As Double

SAFEARRAY

[in, out] SAFEARRAY(double)* or [out] SAFEARRAY(double)*

double[][] single element array containing a 1D array

Dim arr() As Double

SAFEARRAY

[in] SAFEARRAY(CURRENCY) or [in] SAFEARRAY(CURRENCY)* or [out, retval] SAFEARRAY(CURRENCY)*

long[]

Dim arr() As Currency

SAFEARRAY

[in, out] SAFEARRAY(CURRENCY)* or [out] SAFEARRAY(CURRENCY)*

long[][] single element array containing a 1D array

Dim arr() As Currency

SAFEARRAY

[in] SAFEARRAY(DATE) or [in] SAFEARRAY(DATE)* or [out, retval] SAFEARRAY(DATE)*

java.util.Date[]

Dim arr() As Date

SAFEARRAY

[in, out] SAFEARRAY(DATE)* or [out] SAFEARRAY(DATE)*

java.util.Date[][] single element array containing a 1D array

Dim arr() As Date

SAFEARRAY

[in] SAFEARRAY(BSTR) or [in] SAFEARRAY(BSTR)* or [out, retval] SAFEARRAY(BSTR)*

java.lang.String[]

Dim arr() As String

SAFEARRAY

[in, out] SAFEARRAY(BSTR)* or [out] SAFEARRAY(BSTR)*

java.lang.String[][] single element array containing a 1D array

Dim arr() As String

SAFEARRAY

[in] SAFEARRAY(VARIANT) or [in] SAFEARRAY(VARIANT)* or [out, retval] SAFEARRAY(VARIANT)*

java.lang.Object[]

Dim arr() As Variant

SAFEARRAY

[in, out] SAFEARRAY(VARIANT)* or [out] SAFEARRAY(VARIANT)*

java.lang.Object[][] single element array containing a 1D array

Dim arr() As Variant

SAFEARRAY

[in] SAFEARRAY(LPDISPATCH) or [out, retval] SAFEARRAY(LPDISPATCH)*

java.lang.Object[]

Dim arr() As IDispatch

SAFEARRAY

[in, out] SAFEARRAY(LPDISPATCH)* or [out] SAFEARRAY(LPDISPATCH)*

java.lang.Object[][] single element array containing a 1D array

Dim arr() As IDispatch

SAFEARRAY

[in] SAFEARRAY(LPUNKNOWN) or [out, retval] SAFEARRAY(LPUNKNOWN)*

java.lang.Object[]

Dim arr() As IUnknown

SAFEARRAY

[in, out] SAFEARRAY(LPUNKNOWN)* or [out] SAFEARRAY(LPUNKNOWN)*

java.lang.Object[][] single element array containing a 1D array

Dim arr() As IUnknown

SAFEARRAY

[in] SAFEARRAY(ITypename*) or [out, retval] SAFEARRAY(ITypename*)*

java.lang.Object[]

Dim arr() As ITypename

SAFEARRAY

[in, out] SAFEARRAY(ITypename*)* or [out] SAFEARRAY(ITypename*)*

java.lang.Object[][] single element array containing a 1D array

Dim arr() As ITypename

SAFEARRAY

[in] SAFEARRAY(Classname*) or [out, retval] SAFEARRAY(Classname*)*

java.lang.Object[]

Dim arr() As Classname

SAFEARRAY

[in, out] SAFEARRAY(Classname*)* or [out] SAFEARRAY(Classname*)*

java.lang.Object[][] single element array containing a 1D array

Dim arr() As Classname

SAFEARRAY


How COM VARIANTs Map to Java

A VARIANT is a special data structure whose VARTYPE (vt) member can contain any number of different types. J-Integra® supports any VARIANT containing an oleautomation type. The following table lists all the supported types that be contained inside a VARIANT, and their corresponding Java type.

If you are unsure which Variant Types are oleautomation compatible, please see the article Variant Type Definitions. Oleautomation VT types are marked with a [P] (may appear in an OLE property set).

Passing Multi-Dimensional COM Arrays to Java

This table is useful if you wish to pass multi-dimensional COM arrays to Java. A multi-dimensional COM array can be passed as a SAFEARRAY, as described in the above section, or within a VARIANT (see below). J-Integra® currently supports passing two-dimensional (2D) COM arrays, and has limited support for three-dimensional (3D) COM arrays. The limitations for passing 3D COM arrays to Java include:

VARIANT containing:

Maps to Java type:

VARIANT_BOOL

java.lang.Boolean

VARIANT_BOOL*

java.lang.Boolean[] single element array

unsigned char

java.lang.Byte

unsigned char*

java.lang.Byte[] single element array

double

java.lang.Double

double*

java.lang.Double[] single element array

float

java.lang.Float

float*

java.lang.Float[] single element array

long

java.lang.Integer

long*

java.lang.Integer[] single element array

short

java.lang.Short

short*

java.lang.Short[] single element array

BSTR

java.lang.String

BSTR*

java.lang.String[] single element array

CURRENCY

java.lang.Long

CURRENCY*

java.lang.Long[] single element array

Decimal

java.math.BigDecimal

Decimal*

java.math.BigDecimal[] single element array

DATE

java.util.Date

DATE*

java.util.Date[] single element array

SCODE

java.lang.Long

SCODE*

java.lang.Long[] single element array

LPDISPATCH

java.lang.Object

LPDISPATCH*

java.lang.Object[] single element array

LPUNKNOWN

java.lang.Object

LPUNKNOWN*

java.lang.Object[] single element array

ITypename*

java.lang.Object

(ITypename*)*

java.lang.Object[] single element array

Classname*

java.lang.Object

(Classname*)*

java.lang.Object[] single element array

VARIANT

java.lang.Object

VARIANT*

java.lang.Object[] single element array

1D array of any of the above types

java.lang.Object

2D array of any of the above types

java.lang.Object

3D array of VARIANT types

java.lang.Object only supported in DCOM mode

VT_EMPTY

com.linar.jintegra.EmptyVariant.TYPE

VT_NULL

com.linar.jintegra.NullVariant.TYPE


Java Expressions for Converting VB Types to Java Types

The following tables show what Java expression to use if you wish to convert a VB type to a particular Java type. The value passed from VB to Java is represented by the symbol vb. The expressions marked with a * can also raise a Type Mismatch Error.

Java Types: boolean, byte, short, and int

VB (down)/Java(across)

boolean

byte

short

int

Boolean

vb

vb ? 1 : 0

vb ? 1 : 0

vb ? 1 : 0

Byte (0..255)

vb != 0

new Integer(vb).byteValue()

new Integer(vb).shortValue()

new Integer(vb).intValue()

Integer (16 bit)

vb != 0

new Short(vb).byteValue()

vb

new Short(vb).intValue()

Long (32 bit)

vb != 0

new Integer(vb).byteValue()

new Integer(vb).shortValue()

vb

Single

vb != 0.0F

new Float(vb).byteValue()

new Float(vb).shortValue()

new Float(vb).intValue()

Double

vb != 0.0

new Double(vb).byteValue()

new Double(vb).shortValue()

new Double(vb).intValue()

Currency (64 bit)

vb != 0

new Long(vb).byteValue()

new Long(vb).shortValue()

new Long(vb).intValue()

String

new Boolean(vb).booleanValue()

new Long(vb).byteValue()*

new Long(vb).shortValue()*

new Long(vb).intValue()*

Date

Type Mismatch Error

Type Mismatch Error

Type Mismatch Error

Type Mismatch Error

Object

Type Mismatch Error

Type Mismatch Error

Type Mismatch Error

Type Mismatch Error

Java Types: long, char, float, and double

VB/Java

long

char

float

double

Boolean

vb ? 1 : 0

vb ? (char)1 : (char)0

vb ? 1.0F : 0.0F

vb ? 1.0 : 0.0

Byte (0..255)

new Integer(vb).longValue()

(char)(new Integer(vb).intValue())

new Integer(vb).floatValue()

new Integer(vb).doubleValue()

Integer (16 bit)

new Short(vb).longValue()

(char)(new Short(vb).intValue())

new Short(vb).floatValue()

new Short(vb).doubleValue()

Long (32 bit)

new Integer(vb).longValue()

(char)(new Integer(vb).byteValue())

new Integer(vb).floatValue()

new Integer(vb).doubleValue()

Single

new Float(vb).longValue()

(char)(new Float(vb).intValue())

vb

new Float(vb).doubleValue()

Double

new Double(vb).longValue()

(char)(new Double(vb).intValue())

new Double(vb).floatValue()

vb

Currency (64 bit)

vb

(char)(new Long(vb).intValue())

new Long(vb).floatValue()

new Long(vb).doubleValue()

String

new Long(vb).longValue()

(char)(new Long(vb).intValue())

new Long(vb).floatValue()

new Long(vb).doubleValue()

Date

Type Mismatch Error

Type Mismatch Error

Type Mismatch Error

Type Mismatch Error

Object

Error

Error

Error

Error

Java Types: String, Date, and Object

VB/Java

java.lang.String

java.util.Date

java.lang.Object

Boolean

vb + ""

Error

new Boolean(vb)

Byte (0..255)

vb + ""

Error

new Byte(vb)

Integer (16 bit)

vb + ""

Error

new Short(vb)

Long (32 bit)

vb + ""

Error

new Integer(vb)

Single

vb + ""

Error

new Float(vb)

Double

vb + ""

Error

new Double(vb)

Currency (64 bit)

vb + ""

Error

new Long(vb)

String

vb

new Date(vb)

vb

Date

vb.toString()

vb

vb

Object

vb.toString()

Error

vb

* A Variant is converted as above depending on its content!