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

Catch java.lang.System.exit() call #254

Open
rtgdk opened this issue Aug 4, 2017 · 5 comments
Open

Catch java.lang.System.exit() call #254

rtgdk opened this issue Aug 4, 2017 · 5 comments
Assignees
Labels
notice Long standing JPype limitation (outside of our control)

Comments

@rtgdk
Copy link

rtgdk commented Aug 4, 2017

Is there a way to catch java.lang.System.exit() call so that the process does not stop abruptly ?
I am using JPype in a Django application and the connected java app calls System.exit in several methods causing the django server to stop.

@Thrameos
Copy link
Contributor

Thrameos commented Aug 5, 2017

I have not tested this myself but I would assume the correct solution is to use a JProxy to implement a SecurityManager and prevent the System.exit().

See https://stackoverflow.com/questions/5549720/how-to-prevent-calls-to-system-exit-from-terminating-the-jvm

@rtgdk
Copy link
Author

rtgdk commented Aug 5, 2017

JProxy implements interfaces but SecurityManager is a class. How to implement a class in JPype?

@Thrameos
Copy link
Contributor

Thrameos commented Aug 8, 2017

Hmm. I will have to test that. It should be possible to proxy a class. One work around would be to just write a class that does the security exception and load it if the proxy does not work.

@Thrameos Thrameos self-assigned this Jul 30, 2018
@Thrameos
Copy link
Contributor

It is not possible to Proxy a class. Currently the only way to handle this is to create a java class and load it to override the methods. At some point in the future we could create byte code to extend a class from withing python but this it on a long time scale.

@Thrameos Thrameos added the notice Long standing JPype limitation (outside of our control) label May 23, 2019
@Thrameos
Copy link
Contributor

Thrameos commented Apr 6, 2020

This one remains stuck on enhancement #420 which is a long term goal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notice Long standing JPype limitation (outside of our control)
Projects
None yet
Development

No branches or pull requests

2 participants