Re: Issues accessing class attributes of external package distance function
Michael Hall <[email protected]> Tue, 19 Jul 2022 21:37:35 -0500
| Newsgroups | gmane.comp.ai.weka |
|---|---|
| Message-ID | <[email protected]> |
> On Jul 19, 2022, at 8:45 PM, Peter Reutemann <[email protected]> wrote: > >> I am trying to fetch the result of a distance metric, implemented as Weka external package, and use it in python via python-weka-wrapper3. >> >> For this, I augment DilcaDistance.java by the method getMatricesDilca (and build a jar myself), as shown below (most parts of the file are omitted): >> >> https://svn.cms.waikato.ac.nz/svn/weka/trunk/packages/external/DilcaDistance/src/main/java/weka/core/DilcaDistance.java > > [...] > > I just committed some changes to pww3 that allow you to access or call > non-public Java fields/methods Setting accessible would allow this I think. A simple subclass changing the protected access still seems easier to me in this case. It’s also a legitimate java way to do this without bypassing or modifying the access of the class. > (NB: a Java security manager may not > allow this type of access, so your mileage may vary). Security manager is supposedly going away although I’m not completely aware of the specifics of how that’s supposed to work. java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release at java.base/java.lang.System.setSecurityManager(Unknown Source) This seems a real exception but I haven't noticed that it causes my own application any problems. I don’t think the security manager interferes with privileged actions to change accessibility but I’m not positive either. But the recent trend seems to be to eliminate things related to this so what you’re doing might also be in sort of a deprecated status that will eventually stop working. > > The following example script shows the use of the methods > "get_non_public_field" and "call_non_public_method" and also applies > it to the DilcaDistance class: > https://github.com/fracpete/python-weka-wrapper3-examples/blob/master/src/wekaexamples/core/non_public_access.py Possibly this makes it easier from Python if the intention is really to have little or nothing to do with the java. If the intention isn’t to include this in a Weka java based package I’m still unclear on how it is meant to be provided. Again possibly I don’t understand well enough how the Python works. _______________________________________________ Wekalist mailing list -- [email protected] Send posts to [email protected] To unsubscribe send an email to [email protected] To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html