rubicon-java icon indicating copy to clipboard operation
rubicon-java copied to clipboard

Segmentation fault (core dumped) when instantiating the JavaClass

Open Sandro-Meireles opened this issue 2 years ago • 1 comments

Describe the bug I'm not able to instantiate the JavaClass. Segmentation fault (core dumped)

To Reproduce Steps to reproduce the behavior:

  1. Cloned the repository;
  2. Installed the package locally
  3. Ran make
  4. Had to set librubicon.so in RUBICON_LIBRARY environment variable
  5. When I entered the python shell and tried to instantiate the rubicon.java.JavaClass the error happened

Screenshots image image

Environment:

  • Operating System: Ubuntu 20.04.2 LTS
  • Python version: 3.8.10

Additional context I didn't try to install the Briefcase or Toga yet

Sandro-Meireles avatar Mar 26 '22 00:03 Sandro-Meireles

This isn't a bug - it's a feature that isn't currently implemented.

There are two ways to approach the sort of bridge that Rubicon-Java provides:

  1. Embed Python in to the Java Virtual Machine.

  2. Embed a Java Virtual Machine into a running Python process.

Rubicon Java currently implements (1), as this is the mode that is required to implement Android applications. When you run the test suite, it starts a Java app (org.beeware.rubicon.test.Test), which starts a Python VM and runs the unitest suite as Python code.

AFAIK, there's nothing that fundamentally prevents (2) from being implement - it's just a mode of operation that isn't currently supported. It should be relatively straightforward to implement - add a wrapped entry point that instantiates a Java VM (using JNI_CreateJavaVM()) and ensures that the Python method invocation handler is installed. In fact, it would make running the test suite easier, as we would be able to use all the features of Python's test tooling, rather than just the features that are proxied through the Java test wrapper. However, it's not currently a high priority as (a) we have a working test suite, and (b) the 'embedded python' approach is our primary use case.

freakboy3742 avatar Mar 29 '22 03:03 freakboy3742