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
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 个)

类别

Help CenterFile Exchange 中查找有关 Java Package Integration 的更多信息

产品


版本

R14SP2

Community Treasure Hunt

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

Start Hunting!

Translated by