Open drobiazko opened 10 years ago
Not really. Can you give me some insight into why you might want to do this? Once the JVM is destroyed any references to the Java object in JavaScript land would become unusable, then we would need a method to restart it I guess.
We have a Java worker that executes Java jobs. Each job is actually a completely independent Java app with its own set of dependencies. We would like to isolate the classpaths of these Java jobs. I guess just clearing the classpath array won't help.
Do you have any ideas?
Last time I've tried to do so, I've hit a long-standing bug that didn't allow you to re-initialize JVM for the process once it has been deinitialized. I don't know if situation is any different right now.
We could try moving that into a separate method that can be callable from both the deconstructor and a module method. We'd need to define a way to initialize it again though.
This would be awesome. Let me know if you need an alpha tester for this feature.
@jzakrzewski I doubt it. The only way to do this is to unload the JVM shared library.
Any progress on this?
Doubtful. The JVM simply doesn’t have good unloading support right now. @Tomas2D what is your use-case? @drobiazko you can do something similar with classloader trickery.
For example using application with need of different database connections based on application module. Next and not least is E2E tests, where Jest obviously fails to init multiple JVM.
For example using application with need of different database connections based on application module.
Is classloader trickery an option?
Next and not least is E2E tests, where Jest obviously fails to init multiple JVM.
I think your best option is going to be using a cached JVM instance for all tests, or spawning a separate process.
I was able to achieve caching via pretty hacky way in Jest with help of this article http://www.petecorey.com/blog/2018/11/05/bending-jest-to-our-will-caching-modules-across-tests/ .
But I do not understand what do you mean by classloader trickery
, I am using this package - https://github.com/CraZySacX/node-jdbc
But I do not understand what do you mean by
classloader trickery
, I am using this package - https://github.com/CraZySacX/node-jdbc
I know basically nothing about JDBC, but I would imagine there is a way to have multiple database connections in the same JVM.
I see your point, but it looks like, that the mentioned library does not supports that.
Please file a ticket with that library.
Is there any way to invoke this deconstructor from Node code? We'd like to have an API for destroying the JVM.