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

Java loader loaded #559

Closed
wants to merge 13 commits into from
Closed

Conversation

atoulme
Copy link
Contributor

@atoulme atoulme commented Oct 22, 2020

Trying out lazy loader with temp file

@atoulme atoulme marked this pull request as ready for review October 23, 2020 14:18
@atoulme
Copy link
Contributor Author

atoulme commented Oct 24, 2020

This can replace #557.

@axic
Copy link
Member

axic commented Oct 26, 2020

@atoulme is this working now properly?

@atoulme
Copy link
Contributor Author

atoulme commented Oct 26, 2020

It does. I will change the variable name in a separate commit. If you approve I’ll merge.

@atoulme atoulme requested a review from axic October 28, 2020 04:19
@atoulme
Copy link
Contributor Author

atoulme commented Nov 2, 2020

@axic @chfast can I get a review please? Quite a bit waiting downstream from it.

*
* @return true if the library is available
*/
public static boolean isAvailable() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must this be public? Seems to be only used inside create(). Drop it if not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, otherwise another program located in a different java package cannot check if EVMC is available.

try {
Path evmcLib = Files.createTempFile("libevmc-java", extension);
Files.copy(
EvmcVm.class.getResourceAsStream("/libevmc-java." + extension),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what is the best practice for this, but can you use fixed extension for all OSes? E.g. put it in the JAR as java/src/main/resources/libevmc-java.jni and the load as System.load("/tmp/libevmc-java.jni"). You will not have to figure out the OS-specific DLL extension.

Did you test it on Windows? On Windows the DLLs don't have the "lib" prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would want to package all native libraries in the Java jar. This means the jar contains a .so, a .dylib, and a .dll, at a minimum. You can always let folks place the native lib in the path if they want to load their custom library or use a 32 bit system.

I guess the best way to test on Windows would be to have a CircleCI Windows build, I don't have a Windows machine.

@atoulme atoulme force-pushed the java-loader-loaded branch 8 times, most recently from f490b0c to 4be112c Compare November 6, 2020 09:04
@atoulme atoulme force-pushed the java-loader-loaded branch 2 times, most recently from 5b88bd9 to af53ab9 Compare November 6, 2020 09:13
@atoulme atoulme force-pushed the java-loader-loaded branch from af53ab9 to 99abe16 Compare November 6, 2020 09:16
@atoulme
Copy link
Contributor Author

atoulme commented Nov 6, 2020

Can you look at the cmake build failure in Windows? I probably miss something basic.

@axic
Copy link
Member

axic commented Mar 22, 2021

@atoulme so the code here and in #555 is identical, right? And this loader is what you prefer?

I am not sure why this was missed, but if you are happy with the logic here and it works with tuweni, I'll clean this PR up and try to get it merged.

@axic
Copy link
Member

axic commented Mar 23, 2021

Rebased and pushed this entire branch over #557. However dropped Windows support as that can be dealt with later.

@axic axic closed this Mar 23, 2021
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

Successfully merging this pull request may close these issues.

3 participants