Why does calling the value of a JAVA object from its parent class cause MATLAB 7.0.4 (R14SP2) to crash?

1 view (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
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

More Answers (0)

Categories

Find more on Java Package Integration in Help Center and File Exchange

Products


Release

R14SP2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!