MATLAB: Are cell arrays converted to arrays of type java.lang.Object, rather than to a particular type, in MATLAB 7.2 (R2006a)

MATLAB

When passing cell arrays of Java objects to a Java method using auto conversion, I expect the created Java array to have the type of the contained arrays, such as java.util.Hashtable in this example. However, the array is created as an array of type java.lang.Object.
For example, I have the following java class; the hello method of this class accepts a single input which is an array of type Hashtable.
public class MatlabJavaBug {
public static void hello(java.util.Hashtable hash[]) {
System.out.println( "Hello, World!");
}
}
I compile this code and add it to the MATLAB java path as follows:
!javac MatlabJavaBug.java
javaaddpath(pwd)
I then create a Hashtable variable which is the type expected by the above function.
h1 = java.util.Hashtable;
h1.put('a',3);
If I use the javaArray function to create an array of hash tables, the function call is successful.
jHarray = javaArray('java.util.Hashtable',1);
jHarray(1) = h1;
MatlabJavaBug.hello(jHarray)
However, if I create a cell array of hash tables, the command fails
carray = {h1}
MatlabJavaBug.hello(carray)
with the following error message:
??? No method 'hello' with matching signature found for class
'MatlabJavaBug'.
The documentation states that the cell array should be converted to a java array of the appropriate type.

Best Answer

This is an error within the documentation for MATLAB 7.2 (R2006a) within the Calling Java from MATLAB section of the External Interfaces manual.
The documentation should read as follows:
"MATLAB automatically converts the cell array elements to java.lang.Object class objects. Note that in order for a cell array to be passed from MATLAB, the corresponding argument in the Java method signature must specify java.lang.Object or an array of java.lang.Object."
To pass an array to java, you can either manually create an array of objects of the correct type, or modify the Java method to accept arguments of type java.lang.Object.
1. For example to create a Java array of the appropriate type do the following:
jHarray = javaArray('java.util.Hashtable',4);
jHarray(1) = java.util.Hashtable;
jHarray(1).put('a',3);
jHarray(2) = java.util.Hashtable;
jHarray(2).put('a',12);
jHarray(3) = java.util.Hashtable;
jHarray(3).put('a',24);
jHarray(4) = java.util.Hashtable;
jHarray(4).put('a',36);
MatlabJavaBug.hello(jHarray);
2. Alternatively, you can convert the method to have the following signature. Before using the elements of the array, you will need to cast them to the appropriate class. For example the function header would be modified as follows:
public static void hello(java.lang.Object hash[])