cambridge-cares / TheWorldAvatar

A knowledge-graph-based digital twin of the world.
https://theworldavatar.io/
MIT License
77 stars 23 forks source link

py4jps wrapper allows multiple JVMs to be initialised #1230

Closed gpeb2 closed 1 month ago

gpeb2 commented 1 month ago

Each call to jpsBaseLibGW.launchGateway starts a new Java Virtual Machine (JVM) and if you create a Java object in one and then try to pass it to the other then bad things will probably happen. The solution is to make this function create a singleton object that is initialised once and then just returned on subsequent calls.

jb2197 commented 1 month ago

As discussed, the issue is because a new Java gateway object is created when calling JpsBaseLib() which makes Java objects in different JVMs get passed across.