pyjnius icon indicating copy to clipboard operation
pyjnius copied to clipboard

Using autoclassed concrete classes, and pyjnius is complaining that my interface?? objects have no attribute (which are methods on the concrete class)

Open coderextreme opened this issue 8 years ago • 8 comments

Sample project is here https://github.com/coderextreme/pythonSAI. I think I may need to use more than autoclass


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

coderextreme avatar May 06 '17 08:05 coderextreme

Traceback (most recent call last): File "abox.py", line 60, in ProtoInstance29.setIS(IS30) AttributeError: 'org.web3d.x3d.sai.Core.ProtoInstance' object has no attribute 'setIS'

and similar

coderextreme avatar May 10 '17 11:05 coderextreme

Any update on this front? I'm having the same issue 😢

JPDSousa avatar Apr 23 '19 15:04 JPDSousa

I’m guessing it’s related to the getSuperclass call in pyjnius (in the autoclass function I think).

Make sure you are enforcing your interface contracts. Do not return a concrete class, but rather return the interface (or make the types returned match).

John

Sent from Mail for Windows 10

From: João Sousa Sent: Tuesday, April 23, 2019 10:05 AM To: kivy/pyjnius Cc: John Carlson; Author Subject: Re: [kivy/pyjnius] Using autoclassed concrete classes, and pyjnius iscomplaining that my interface?? objects have no attribute (which are methodson the concrete class) (#270)

Any update on this front? I'm having the same issue 😢 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

coderextreme avatar Apr 23 '19 20:04 coderextreme

I caught this issue while doing a getClass over an interface object

JPDSousa avatar Apr 24 '19 18:04 JPDSousa

I don’t think there’s such a thing as an interface object??? I know what you mean though.

On Wed, Apr 24, 2019 at 1:24 PM João Sousa [email protected] wrote:

I caught this issue while doing a getClass over an interface object

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kivy/pyjnius/issues/270#issuecomment-486370305, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFMJ56DIQB3TVU552LDDBLPSCQWTANCNFSM4DKKXREQ .

coderextreme avatar Apr 24 '19 18:04 coderextreme

What I mean is that I have a given class that returns an interface type and for some reason I cannot do a getClass over that result object, as it throws a no attribute error. The strange thing is that find_javaclass.isInstance does not work as well, as it always returns false, even when I load the interface type.

JPDSousa avatar Apr 24 '19 20:04 JPDSousa

Yeah, you’ll have to dig into pyjnius I guess, if you don’t want to change your code. You can call a similar method with a different signature in your implementing class, which returns an instance of a concrete class which inherits from the interface, but does not declare the similar method in the interface. GL What I am doing is implementing primitive type wrappers around my parameters, so that the concrete class method is selected instead of the interface method. It’s like you’re ignoring the interface though.

I do not like it. If your implementing class does return an interface type just like the interface does, I suggest that the super class is overriding the subclass and blocking the implementation, but I haven’t proved anything satisfactorily yet. I need to start up a debugger, but not sure which one to use with kivy.

Basically, my “boss” is overly optimistic, and I am pessimistic because I am just a newb at Python. We need help from the pyjnius experts!

Another solution is not to use return values. YMMV

John

Sent from Mail for Windows 10

From: João Sousa Sent: Wednesday, April 24, 2019 3:55 PM To: kivy/pyjnius Cc: John Carlson; Author Subject: Re: [kivy/pyjnius] Using autoclassed concrete classes, and pyjnius iscomplaining that my interface?? objects have no attribute (which are methodson the concrete class) (#270)

What I mean is that I have a given class that returns an interface type and for some reason I cannot do a getClass over that method, as it throws a no attribute error. The strange thing is that find_javaclass.isInstance does not work as well, as it always returns false, even when I load the interface type. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

coderextreme avatar Apr 24 '19 22:04 coderextreme

Also complains on abstract classes in addition to interfaces

carlsonsolutiondesign avatar May 12 '19 01:05 carlsonsolutiondesign

👋 We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please use our support channels to get help with the project. Let us know if this comment was made in error, and we'll be happy to reopen the issue.

github-actions[bot] avatar Oct 28 '23 01:10 github-actions[bot]