[x3d-public] Don, important information Re: AttributeError's in *.future.py files in X3D Python

John Carlson yottzumm at gmail.com
Wed Apr 10 14:45:21 PDT 2019


Don wrote:

John, wondering if you can just map all the concrete nodes in a scene graph to the corresponding concrete objects in X3DJSAIL.  That will avoid all of the "abstract method not found" errors.  The X3D abstract classes are specification-defined and helpful and good to expose programmatically, but they are never needed when translating .x3d or other file encodings (uh, since they are abstract).

* "A concrete class is a class that can be instantiated, as opposed to abstract classes, which cannot."
   https://en.wikipedia.org/wiki/Class_(computer_programming)#Abstract_and_concrete

I guess you’re talking about abox.future.py, and this error:

python abox.future.py
Traceback (most recent call last):
  File "abox.future.py", line 63, in <module>
    .setProtoField("myShape") \
  File "jnius\jnius_export_class.pxi", line 760, in jnius.JavaMethod.__call__
  File "jnius\jnius_conversion.pxi", line 78, in jnius.populate_args
  File "jnius\jnius_utils.pxi", line 205, in jnius.check_assignable_from
jnius.JavaException: Invalid instance of 'org/web3d/x3d/jsail/X3DConcreteNode' passed for a 'org/web3d/x3d/sai/Core/X3DNode'

I don’t know what’s causing this.   Maybe PyJNIus is buggy.  It looks really weird

Here is the import, as far as I can tell:

from org.web3d.x3d.jsail.Core.connectObject import connectObject as connect

Here is the implementing code of the Python/Java class:

from jnius import autoclass
connectObject = autoclass('org.web3d.x3d.jsail.Core.connectObject')

I suggest we punt on this error for a while, and work on the  AttributeError’s? You’re seeing those?

Please check in a new X3D file that we can test with into the pyjnius folder. Thanks!

I suggest this one:

processSingleScene.pythonValidation:
     [echo] processSingleScene.python C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors\Chapter02GeometryPrimitives\GeometryPrimitiveNodes.future.py
     [echo] Loading X3D model as .py program, if successful then saving as round-trip .x3d version:
     [exec] Traceback (most recent call last):
     [exec]   File "C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors\Chapter02GeometryPrimitives\GeometryPrimitiveNodes.future.py", line 63, in <module>
     [exec]     .setTranslation([-5,0,0]) \
     [exec] AttributeError: 'org.web3d.x3d.sai.Grouping.Transform' object has no attribute 'addChild'
     [exec] Result: 1
     [echo] =====================

Note the use of the interface here.  There is no addChild on the interface.   Thus much of our “pipelining” will fail 

Here I the declaration of Transform:

from org.web3d.x3d.jsail.Grouping.TransformObject import TransformObject as Transform

concrete.  Where is the interface coming from?  Let’s look at setTranslation.

In the interface, it’s listed as:

public Transform setTranslation(float[] newValue);

Transform comes from the sai.Grouping package in this interface.   So it returns an interface, right?

Let’s look at the concrete class in jsail/Grouping/TransformObject.java:

public TransformObject setTranslation(float[] newValue)

It doesn’t return the same type as the interface. Isn’t this breaking the interface contract that TransformObject pledges to have when it implements the interface?

So since the interface is broken, the next line of code fails:

.addChild(Shape() \

Subtle, huh? I do not know why the Java compiler doesn’t throw tons of exceptions about this.

I would report the error to Oracle.  They should at least report a potential issue with a broken contract.

I suggest that all setters return something in the sai code.  I think that will clean up a bunch of our errors as you repair X3DJSAIL.

That sucks, right?  I suggest that we abandon *.future.py until we get a pure python API.  Have I stated my reasoning appropriately?

Sorry it took me so long to describe this, and all my irateness.  It was my fault for knowing what the problem was and not describing it adequately before.

John

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190410/6c145e9a/attachment.html>


More information about the x3d-public mailing list