Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[submodule "external/Java.Interop"]
path = external/Java.Interop
url = https://github.com/xamarin/java.interop.git
branch = main
branch = dev/jonp/ji-typemap-support
[submodule "external/lz4"]
path = external/lz4
url = https://github.com/xamarin/lz4
Expand Down
2 changes: 1 addition & 1 deletion external/Java.Interop
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public List<JavaType> GetJavaTypes (ICollection<ITaskItem> inputAssemblies, XAAs

void AddJavaType (TypeDefinition type, Dictionary<string, TypeData> types, AndroidTargetArch arch)
{
if (type.IsSubclassOf ("Java.Lang.Object", cache) || type.IsSubclassOf ("Java.Lang.Throwable", cache) || (type.IsInterface && type.ImplementsInterface ("Java.Interop.IJavaPeerable", cache))) {
if (type.ImplementsInterface ("Java.Interop.IJavaPeerable", cache)) {
// For subclasses of e.g. Android.App.Activity.
string typeName = type.GetPartialAssemblyQualifiedName (cache);
if (!types.TryGetValue (typeName, out TypeData typeData)) {
Expand Down
14 changes: 14 additions & 0 deletions src/monodroid/jni/embedded-assemblies.cc
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,20 @@ EmbeddedAssemblies::typemap_java_to_managed (hash_t hash, const MonoString *java

if (module->image == nullptr) {
module->image = mono_image_loaded (module->assembly_name);

if (module->image == nullptr) {
log_debug (LOG_ASSEMBLY, "typemap: assembly '%s' hasn't been loaded yet, attempting a full load", module->assembly_name);

// Trigger MonoVM's machinery to load an image. This will involve calling us back to find, uncompress (if
// necessary) and load the assembly from whatever storage the app uses.
MonoImageOpenStatus status{};
module->image = mono_image_open (module->assembly_name, &status);

if (status != MonoImageOpenStatus::MONO_IMAGE_OK) {
log_warn (LOG_ASSEMBLY, "typemap: failed to load managed assembly image '%s'. %s", module->assembly_name, mono_image_strerror (status));
}
}

if (module->image == nullptr) {
log_error (LOG_ASSEMBLY, "typemap: unable to load assembly '%s' when looking up managed type corresponding to Java type '%s'", module->assembly_name, to_utf8 (java_type_name).get ());
return nullptr;
Expand Down