What to do with (py4j.java_gateway.JavaMember object..)?

Hello,
Starting from a variable containing a “Capella Module” element (from the Req Addon). When calling its eClass(), it gives me:

org.eclipse.emf.ecore.impl.EClassImpl@5a9bb7dd (name: CapellaModule) (instanceClassName: null) (abstract: false, interface: false)

Yet weirdly enough, calling its name (*with print(Seaching2.eClass().name)*), it would give this:

<py4j.java_gateway.JavaMember object at 0x000002970A803C08>

Not sure how use that item?

KaBe

The Object you are referencing here is the Java Object. You will need to use the name of the Java method:

eClass().getName()

You are right, I had used getname() with “n” instead or “N” for the word name (getname() instead of getName()).
I was confused because (and I find that intriguing):

Seaching2.eClass().get_java_object()
Seaching2.get_java_object()

Did not work.

py4j.protocol.Py4JError: An error occurred while calling o614.get_java_object. Trace:
py4j.Py4JException: Method get_java_object([]) does not exist

The get_java_object() method is defined by Python4Capella on the JavaObject class. This allows to access the Java Object (in the JVM memory) of any Python4Capella Object if needed. Once you have a Java Object (in the JVM memory), you can’t call this method anymore on it but only Java defined methods.

In your case here Seaching2 is a Java Object (in the JVM memory). To check this you can use the Python function type() to see the difference:

print(type(someObject))
1 Like