Skip to content

Conversation

@radekdoulik
Copy link
Member

Prepare dllmap override in Java.Interop repo to have
Java.Runtime.Environment.dll working with our libmono-android shared
library.

Introduced build-tools/scripts/java-interop.dllmap to share that
information between Java.Interop.dll.config and
Java.Runtime.Environment.dll.config.

@radekdoulik radekdoulik requested a review from jonpryor as a code owner May 28, 2018 14:57
@jonpryor
Copy link
Contributor

Unfortunately, as also seen in PR #1734, current Java.Interop won't build on our Azure Ubuntu instances, as the JVM can't be found:

error MSB4018: The "JdkInfo" task failed unexpectedly.
error MSB4018: System.ArgumentNullException: Value cannot be null.
error MSB4018: Parameter name: v1
error MSB4018:   at System.Version.op_LessThanOrEqual (System.Version v1, System.Version v2) [0x00003] in <2f83d2ff70e3444cb3582fe4e97bad63>:0 
error MSB4018:   at Java.Interop.BootstrapTasks.JdkInfo+<>c__DisplayClass31_0.<GetJavaHomePathFromMachine>b__2 (<>f__AnonymousType0`2[<Path>j__TPar,<Version>j__TPar] v) [0x00000] in /mnt/jenkins/workspace/xamarin-anroid-linux-pr-builder/xamarin-android/external/Java.Interop/src/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs:172 
error MSB4018:   at System.Linq.Enumerable+WhereEnumerableIterator`1[TSource].ToArray () [0x0001d] in <109ebca7234742db851e0fefa714a103>:0 
error MSB4018:   at System.Linq.Buffer`1[TElement]..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x0000a] in <109ebca7234742db851e0fefa714a103>:0 
error MSB4018:   at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext () [0x0001e] in <109ebca7234742db851e0fefa714a103>:0 
error MSB4018:   at System.Linq.Enumerable+SelectIPartitionIterator`2[TSource,TResult].ToList () [0x00052] in <109ebca7234742db851e0fefa714a103>:0 
error MSB4018:   at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <109ebca7234742db851e0fefa714a103>:0 
error MSB4018:   at Java.Interop.BootstrapTasks.JdkInfo.GetJavaHomePathFromMachine (System.Version maxVersion) [0x00015] in /mnt/jenkins/workspace/xamarin-anroid-linux-pr-builder/xamarin-android/external/Java.Interop/src/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs:163 
error MSB4018:   at Java.Interop.BootstrapTasks.JdkInfo.Execute () [0x00176] in /mnt/jenkins/workspace/xamarin-anroid-linux-pr-builder/xamarin-android/external/Java.Interop/src/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs:56 
error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in <bdc5207a22bb42ae9fe3f3d07e82871e>:0 
error MSB4018:   at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteInstantiatedTask>d__26.MoveNext () [0x00212]
...
make[1]: *** No rule to make target 'bin/BuildDebug/JdkInfo.mk', needed by 'prepare'.  Stop.

See also: dotnet/java-interop#327

@jonpryor
Copy link
Contributor

Please rebase now that PR #1747 is merged.

…blies

Use `jnimarshalmethod-gen` on resolved user assemblies. As a preview
feature it is conditional and only enabled when `JniMarshalMethods` is
True.

This feature implements main part of
https://github.com/xamarin/xamarin-android/projects/1
Prepare dllmap override in Java.Interop repo to have
Java.Runtime.Environment.dll working with our libmono-android shared
library.

Introduced `build-tools/scripts/java-interop.dllmap` to share that
information between `Java.Interop.dll.config` and
`Java.Runtime.Environment.dll.config`.
@radekdoulik radekdoulik force-pushed the pr-prepare-Java.Runtime.Environment.Override.dllmap branch from 597b411 to 3af2f69 Compare May 30, 2018 10:54
@radekdoulik radekdoulik requested a review from dellis1972 as a code owner May 30, 2018 10:54
@jonpryor
Copy link
Contributor

This broke all the Java.Interop unit tests, for example:

OneTimeSetUp: System.TypeInitializationException : The type initializer for 'Java.InteropTests.JavaVMFixture' threw an exception.
  ----> System.DllNotFoundException : lib/host-Darwin/libmono-android.debug.dylib

Looking at the contents of xamarin.android-oss_v8.3.99.229_Darwin-x86_64_HEAD_f1c953a.zip, I see that lib/xamarin.android/xbuild/Xamarin/Android/Java.Interop.dll.config is:

configuration>
<dllmap dll="java-interop" os="osx" target="lib/host-Darwin/libmono-android.debug.dylib" />
<dllmap dll="java-interop" os="linux" target="lib/host-Linux/libmono-android.debug.so" />
<dllmap dll="java-interop" os="windows" wordsize="64" target="lib/host-mxe-Win64/libmono-android.debug.dll" />
<dllmap dll="java-interop" os="windows" wordsize="32" target="lib/host-mxe-Win32/libmono-android.debug.dll" />
</configuration>

That explains where lib/host-Darwin/libmono-android.debug.dylib is coming from...

lib/xamarin.android/xbuild/Xamarin/Android/lib/host-Darwin/libmono-android.debug.dylib does exist in the xamarin-android-oss*.zip file, so there is a library to find, it's just not being found.

I suspect that "a fix" would be place a full path into the //dllmap/@target attribute value, but that in turn means it couldn't be "relocated" and would need to use the system-wide install location:

<dllmap dll="java-interop" os="osx" target="/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild/Xamarin/Android/lib/host-Darwin/libmono-android.debug.dylib" />

That's not a good fix, mind you, but it should allow things to progress on macOS...assuming that the build machine has a system-wide Xamarin.Android install which is relatively recent.

I believe a "better" fix is: dotnet/java-interop#321 (comment)

  1. "Plumb" the Java.Interop APIs so that the path to libmono can be provided at runtime.

@radekdoulik
Copy link
Member Author

I think the Java.Interop.dll.config should be fine here. Its content should be the same as before this patch.

The problem is Java.Runtime.Environment.Override.dllmap which we generate in Java.Interop with intention to consume it in Xamarin.Android. But it stays in the Java.Interop as well and then we run the tests in Java.Interop and the things blow up, because there we don't have the libmono-android.debug.so available.

I will try to modify it so that we generate two configs in Java.Interop. One for Java.Interop which will be the same as before and another for Xamarin.Android with injected dllmap to copy and use in Xamarin.Android.

@radekdoulik
Copy link
Member Author

In the end I looks better to modify the config file directly in XA, so I created #1761 for that. It keeps the Java.Interop local configs unchanged, so tests should run OK and only XA copy is modified.

That would also avoid another PR rountrip to modify Java.Interop and Xamarin.Android.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants