ActiveX client programming, tips for passing arrays
Arrays are very similar between Java and Automation containers like Visual Basic and VBScript. This topic provides some important points to consider when passing arrays back and forth between these containers.
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 code:
... Dim VariantArray(1) as Variant VariantArray(0) = CLng(123) VariantArray(1) = CDbl(123.4) oMyJava Object.foo(VariantArray) ' Illegal!VariantArray(0) = CLng(123) VariantArray(1) = CLng(1234) oMyJava Object.foo(VariantArray) ' This works
- Arrays 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 oJava Objects(1) as Object), set each object to a JObjectProxy object before you send the array to a Java object. 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 multidimensional arrays are treated as zero-based multidimensional arrays in Visual Basic and VBScript containers.
- 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.
 
Related concepts
ActiveX to EJB Bridge
Related tasks
Develop ActiveX client application code
Related
ActiveX to Java primitive data type conversion values
ActiveX client programming best practices