How to deal with a "JavaMember object"? (Result of a .target parameter)

Hello,
I was handling a “node” and wanted to apply a “target” to it, in order to obtain the normal element (the one listed in the project explorer i guess),

I applied it to a “function node”, and obtained a variable containing a JavaMember object!

Like this one:

<py4j.java_gateway.JavaMember object at 0x0000025608079C48>

This does not seem to look like anything I have dealt with in the past, indeed wraping it into a python object just did not work:

wrap = EObject.get_class(ElemTar)(ElemTar)
print(wrap)

Result: AttributeError: ‘JavaMember’ object has no attribute ‘eClass’

How Could I deal with this please?

Thanks.
Best R

py4j.java_gateway.JavaMember is a Py4J internal class… I don’t know how you can reference it from Python.
The EObject.get_class() methods needs a Java EObject as parameter to get it’s EClass and see if we can find a corresponding Python class to later do some type checking or wrap the Java EObject. And JavaMember is not an EObject.

Indeed this is a very interesting issue.

Well using “target” on a any node java object variable, seem to get us that instead of a normal java object.
So there would be method to handle a JavaMember,

Or maybe find an alternative to find the target other than aNode.target?


Example result of “print(aNode)”:

Node Constant --> org.polarsys.capella.core.data.ctx.impl.SystemFunctionImpl@6ce543b4 (id: 08559f95-ae

Applying the target (print(aNode.target), the result is:

<py4j.java_gateway.JavaMember object at 0x0000025608079C48>

I am basically trying to do this:

But in python, however I am obtained an item that I can’t seem be able to use.
(Self here is a node), maybe there are other solutions to achieve this?

You can use:

aNode.getTarget()
1 Like