You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building most of my classes in MSch as Matlab classdef wrappers around the corresponding Java objects. The pattern looks like this:
classdefIdentity < handleproperties (SetAccess=private, Hidden=true)
% The underlying com.jcraft.jsch.Identity Java objectjendproperties (Dependent)
namealgorithmNameisEncryptedendmethodsfunctionthis= Identity(jIdentity)
ifnargin==0returnend
mustBeA(jIdentity, 'com.jcraft.jsch.Identity');
this.j =jIdentity;
endfunctionout=get.name(this)
out = string(this.j.getName);
endfunctionout=get.algorithmName(this)
out = string(this.j.getAlgName);
endfunctionout=get.isEncrypted(this)
out =this.j.isEncrypted;
endendend
That j property is intended to hold the wrapped Java object.
But it's necessary to allow for Matlab objects that have an empty j value: it's not possible in all cases to construct appropriate default underlying Java object values efficiently or at all. And we need to be able to construct "null" or "uninitialized" Matlab objects, for the cases when we need to pre-allocate an array (e.g. idents = repmat(msch.Identity, [1 n]);) or construct a default object instance to conform to declarative type constraint requirements on properties in other objects.
For these "uninitialized" objects, j is [], so the get.XXX(this) methods will fail, because they try to do a method call on [], which is a double that doesn't support those methods. And the default object disp()/display() for scalar objects will call those methods, because it tries to call those methods. What happens is that those properties appear to not exist in the object display (it doesn't throw an error).
Should I do something to handle this more gracefully?
Custom disp() that displays " (uninitialized)" for uninitialized objects?
Alter the get.* methods to return default values when j is empty?
I think this is just a cosmetic issue, since display doesn't actually raise an error.
The text was updated successfully, but these errors were encountered:
I'm building most of my classes in MSch as Matlab
classdef
wrappers around the corresponding Java objects. The pattern looks like this:That
j
property is intended to hold the wrapped Java object.But it's necessary to allow for Matlab objects that have an empty
j
value: it's not possible in all cases to construct appropriate default underlying Java object values efficiently or at all. And we need to be able to construct "null" or "uninitialized" Matlab objects, for the cases when we need to pre-allocate an array (e.g.idents = repmat(msch.Identity, [1 n]);
) or construct a default object instance to conform to declarative type constraint requirements on properties in other objects.For these "uninitialized" objects,
j
is[]
, so theget.XXX(this)
methods will fail, because they try to do a method call on[]
, which is adouble
that doesn't support those methods. And the default objectdisp()
/display()
for scalar objects will call those methods, because it tries to call those methods. What happens is that those properties appear to not exist in the object display (it doesn't throw an error).Should I do something to handle this more gracefully?
disp()
that displays " (uninitialized)" for uninitialized objects?get.*
methods to return default values whenj
is empty?I think this is just a cosmetic issue, since
display
doesn't actually raise an error.The text was updated successfully, but these errors were encountered: