Why does calling the value of a JAVA object from its parent class cause MATLAB 7.0.4 (R14SP2) to crash?
1 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
MathWorks Support Team
2009-6-27
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Java Package Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!