Array tips for ActiveX application clients
Arrays are very similar between Java and Automation Containers like Visual Basic and VBScript. Here are some important points to consider when passing arrays back and forth between these containers:
Java arrays cannot mix types. All Java arrays contain a single type, so when passing arrays of Variants to a Java Array, make sure that all of the elements in the Variant array are of the same base type. For example, in Visual Basic:
... Dim VariantArray(1) as Variant VariantArray(0) = CLng(123) VariantArray(1) = CDbl(123.4) oMyJavaObject.foo(VariantArray) ' Illegal! VariantArray(0) = CLng(123) VariantArray(1) = CLng(1234) oMyJavaObject.foo(VariantArray) ' This worksArrays of Primitive Types are converted using the rules defined in Primitive Data Type Conversion.
Arrays of Java Objects are handled through arrays of JObjectProxy objects.
Arrays of JObjectProxy objects must be fully-initialized and of the correct associated Java type. When initializing an array in Visual Basic (for example, Dim oJavaObjects(1) as Object), set each object to a JObjectProxy before you send the array to Java. The bridge is unable to determine the type of null or empty Object values.
When receiving an array from a Java method, the lower-bound is always zero. Java methods only support zero-based arrays.
Nested or multi-dimensional arrays are treated as zero-based multi-dimensional arrays in Visual Basic and VBScript.
Uninitialized arrays or Array Types are unsupported. When calling a Java method that takes an array of objects as a parameter, fully initialize the array of JObjectProxy objects.