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)
Show older comments
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
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
0 Comments
More Answers (0)
See Also
Categories
Find more on Java Package Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!