-
Notifications
You must be signed in to change notification settings - Fork 63
[libjava-interop] Use own DylibMono instance #321
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
[libjava-interop] Use own DylibMono instance #321
Conversation
aeac378 to
18a7e17
Compare
|
I'm not sure I understand this change or the need for this specific change. As per the earlier comment, you're going to update This might work on macOS because This will fail on Windows, because I believe what we need to do is make
That way, things at least have a chance of working on Windows, and we'll make the java-interop test environment closer-in-spirit to what xamarin-android does. |
|
OK, I wasn't aware about the situation on Windows, so I expected |
Yes, plus we need to add Java.Interop.dll.config as well. (for https://github.com/xamarin/java.interop/blob/master/src/Java.Interop/Java.Interop/JniEnvironment.cs#L168) |
|
Thinking more about it, I think on Windows it should work as well. We will be running |
|
Will |
|
Tried to test it on Windows. Looks like we might indeed need to specify the mono runtime library path. It is not completely clear, but likely. The mono is crashing silently and the debug output looks incomplete. End of When I tried to pass the mono library path, it got a bit further and crashed silently again. The end of output of updated run: So it looks like we will have to fix more issues on Windows.
Therefore I would like to merge this PR as is, so that I can finish the new methods marshaling on mac and then get back and fix remaining issues on Windows. Sounds good? |
|
I still don't understand why this patch is needed.
It seems that the primary purpose here is to call If that's the actual problem, couldn't we instead just call We know that mid-term |
18a7e17 to
629b0eb
Compare
That is right.
That would work too. I considered that before, but because didn't think of it as a hack at that time, I didn't find good place to do it. Updated the patch and used beginning of |
| if (jvm == NULL) | ||
| return NULL; | ||
|
|
||
| if (!monodroid_dylib_mono_init (monodroid_get_dylib (), NULL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...how does this build and run on the PR builder?
That this works at all without #if is blowing my mind.
Looking at the build log, we're seeing the warning I would expect to see:
java-interop-gc-bridge-mono.c(265,7): warning G84A3CD4A: implicit declaration of function 'monodroid_dylib_mono_init' is invalid in C99 [-Wimplicit-function-declaration] [/Users/builder/jenkins/workspace/Java.Interop-pr-builder/src/java-interop/java-interop.csproj]
if (!monodroid_dylib_mono_init (monodroid_get_dylib (), NULL)) {
^
Good thing we don't have "warning as errors" enabled! ;-)
Reading further, my mind is no longer blown: it's blowing up during unit tests:
mono --debug packages/NUnit.ConsoleRunner.3.7.0/tools/nunit3-console.exe bin/TestDebug/Java.Interop-Tests.dll --result="TestResult-Java.Interop-Tests.xml;format=nunit2" --output="bin/TestDebug/TestOutput-Java.Interop-Tests.txt"
...
Test Files
bin/TestDebug/Java.Interop-Tests.dll
dyld: lazy symbol binding failed: Symbol not found: _monodroid_get_dylib
Referenced from: /Users/builder/jenkins/workspace/Java.Interop-pr-builder/bin/TestDebug/libjava-interop.dylib
Expected in: flat namespace
dyld: Symbol not found: _monodroid_get_dylib
Referenced from: /Users/builder/jenkins/workspace/Java.Interop-pr-builder/bin/TestDebug/libjava-interop.dylib
...
/Users/builder/jenkins/workspace/Java.Interop-pr-builder/build-tools/scripts/RunNUnitTests.targets(30,5): error MSB3073: The command "mono --debug packages/NUnit.ConsoleRunner.3.7.0/tools/nunit3-console.exe bin/TestDebug/Java.Interop-Tests.dll --result="TestResult-Java.Interop-Tests.xml;format=nunit2" --output="bin/TestDebug/TestOutput-Java.Interop-Tests.txt"" exited with code 156.
Build continuing because "ContinueOnError" on the task "Exec" is set to "ErrorAndContinue".
Done Building Project "/Users/builder/jenkins/workspace/Java.Interop-pr-builder/build-tools/scripts/RunNUnitTests.targets" (default targets) -- FAILED.
Build FAILED.
Given that it clearly failed...WHY DIDN'T IT FAIL?!
Now my mind is blown, just differently from before. :-(
With that exploration out of the way...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if block needs to be wrapped in #if defined (ANDROID) || defined (DYLIB_MONO):
#if defined (ANDROID) || defined (DYLIB_MONO)
if (!monodroid_dylib_mono_init (monodroid_get_dylib (), NULL)) {
log_fatal (LOG_DEFAULT, "mono runtime initialization error: %s", dlerror ());
exit (FATAL_EXIT_CANNOT_FIND_MONO);
}
#endif /* defined (ANDROID) || defined (DYLIB_MONO) */There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh, indeed. At least we have the PR builder fixed as well. Good catch!
|
hopefully I've fixed the PR builder, so... |
|
build |
Temporarily initialize monodroid's mono dylib from GC bridge. This will need to be updated later with proper path to *libmonosgen* shared library to make it work on Windows.
629b0eb to
a6df74d
Compare
The monodroid's DylibMono is initialized in
Java_mono_android_Runtime_initand thus not avaiable forstandalone Java.Interop consumers, like
jnimarshalmethod-gen.exe.Let
libjava-interophave its own DylibMono instance and initializeit on first call to mono functions.
We might rethink that once we start using libjava-interop's GC bridge
in monodroid.