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

[BridJ, OSGi] Platform.DeleteFiles: process uses java.class.path, finds equinox.launcher.jar in equinox/OSGi context and fails #64

Open
mfriedemann opened this issue May 5, 2015 · 3 comments

Comments

@mfriedemann
Copy link
Contributor

I am using BridJ in an equinox/OSGi context and while it works fine, it requires a bit of additional effort for the setup and cleanup steps.

I finally got around to look into the cleanup, which, under the equinox/OSGi context, failed to remove the temporary files and their target directory.
The issue is that while it identifies the files and marks them for deletion to be completed in the shutdown hook, the process it starts uses the existing java.class.path environment variable.
For equinox/OSGi, this variable is, however, set to the equinox launcher jar file, which the Platform.DeleteFiles class is obviously not a part of.

For now, I am working around this specific issue by setting up another shutdown hook that first finds the proper bridj jar from the OSGi bundle and then sets the java.class.path variable to that jar file.

I would like to propose an enhancement (either of BridJ's OSGi specifics or to BridJ in general), that actually tries to find the bridj.jar itself and uses it as the sub-process' classpath.

Regards,
Marko

@MichaelEnke
Copy link

MichaelEnke commented Nov 9, 2020

Another way to circumvent the deletion problem (on windows only, I guess) would be to use the envirnoment variable or property to point to bridj.dll or bridj.so. This requires to have the library extracted manually before.
It would be better to call the createTempDir() (in Platform.java) not in the static block (which executes always) but in initLibrary() when forceLibFile is null.
That would avoid the temp file creation and deletion.

@mfriedemann
Copy link
Contributor Author

Hm, I am not sure this is possible.
AFAICS dlopen/LoadLibrary can't load native library files from archive files, which makes the extraction into a temporary directory and its deletion upon exiting mandatory.

M.

@MichaelEnke
Copy link

I meant and wrote that manual extraction is required. As it is now, without having the bridj jar in the classpath property (which is the case for projects building its classpath themselves), the temp dirs are not deleted.

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

2 participants