MATLAB: Does calling the value of a JAVA object from its parent class cause MATLAB 7.0.4 (R14SP2) to crash

crashjavaMATLABobjectreturn

I use the following steps:
1. Create a simple JAVA class:
public class Matrix {
public Object m;
public Matrix(Object v) {
m = v;
}
public Object getM() {
return m;
}
}
2. From within MATLAB, create the JAVA object:
obj = Matrix(rand(3));
3. Retrieve the value of the object:
m = obj.m; % this crashes MATLAB
Step 3 causes MATLAB to crash.

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This behavior is due to a known bug in MATLAB 7.0.4 (R14SP2). The workaround is to create a new method within the parent class that returns the value of the target object, and then call the method.
For example, to retrieve the value of the object:
1. Create a simple JAVA class:
public class Matrix {
public Object m;
public Matrix(Object v) {
m = v;
}
public Object getM() {
return m;
}
}
2. From within MATLAB, create the JAVA object:
obj = Matrix(rand(3));
3. Replace step 3 from above with the following:
m = obj.getM; % this works