Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: JVM cannot be restarted. #959

Closed
empty2enrich opened this issue Apr 6, 2021 · 5 comments
Closed

ERROR: JVM cannot be restarted. #959

empty2enrich opened this issue Apr 6, 2021 · 5 comments

Comments

@empty2enrich
Copy link

stop jvm, then start jvm, get this error.

my code:

def test():
  jpype.startJVM()
  ...... other code
  jpype.shutdownJVM()

if __name__ == "__main__":
  test()
  test()
@john-hen
Copy link

john-hen commented Apr 6, 2021

This is expected behavior, in that it's a documented limitation. See API doc of jpype.shutdownJVM():

This method shuts down the JVM and disables access to existing Java objects. Due to limitations in the [sic] JPype, it is not possible to restart the JVM after being terminated.

@pelson
Copy link
Contributor

pelson commented Apr 6, 2021

A few other issues worth linking to: #393 (comment), and #84 (comment).

This isn't a limitation introduced by JPype, but rather by the underlying JNI.

(I can't close the issue, but recommend it should be closed as a "can't fix")

@empty2enrich
Copy link
Author

can't fix

@leopoletti
Copy link

Hello,

I know it cannot be fixed through jpype but is there any workaround based on what happen when the kernel is restarted? variable/memory cleaning link to JVM that we can perform may be without restarting the kernel?

@Thrameos
Copy link
Contributor

I am not sure what you are referring to by kernel. The JVM is a process level library and thus it lives as long as the process unless terminated prematurely with "shutdownJVM". It has nothing to do with the kernel.

The official JVM stopped supporting restarting capabilities in Java 1.2 and there are as far as I know no implementations with the capability. The JNI supports restarting or multiple JVMs, but without support from the JVM that is just useless capabilities.

Unfortunately they uses statics in the JVM so that no more than one copy can be installed, and once started it installs OS hooks that it does not remove. Thus you can't even unload the JVM shared library and reload it to create a fresh copy.

I personally feel that having a user callable "shutdown" is a mistake in JPype design. The JVM was never intended to be run as a submodule. Once started it needs to run until of the process. Only when the process is preparing to exit should the JVM ever be told to begin shutdown procedures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants