[Java.Interop.Tools.JavaCallableWrappers] Fix android.app.Application #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
android.app.Application is special: Android contructs it before the
mono runtime has been initialized, requiring that the
activation constructor be used for all Android.App.Application
subclasses:
As a consequence of this, the Android.App.Application..ctor() default
constructor is never used in normal use, which means that the linker
is free to remove it.
This in turn means that in Release (linked) apps, no constructor
would be present in the
MyAppJava Callable Wrappers, becauseconstructor generation requires that the binding assembly contain the
constructor to emit.
This is kinda/sorta fine, in that the Java compiler-provided default
constructor would still be emitted, allowing the
MyAppJava Callable Wrapper to be constructed, but that's only true so long
as the default constructor is sufficient.
Unfortunately, the default constructor isn't always sufficient: on
certain Android versions (API <= 15), the Application instance isn't
provided to the bootstrap
MonoRuntimeProvider.attachInfo()method,which means that the Android.App.Application.Context property returns
the wrong value.
Fixing this requires updating the Java Callable Wrapper of the
Application subclass to contain code to preserve the first Application
instance created in the process, which in turn means the default
Application constructor is no longer sufficient.
Update JavaCallableWrapperGenerator so that (in Debug builds) the
default Application constructor is skipped, and in all
configurations a custom constructor is generated within the
Java Callable Wrapper for android.app.Application subclasses.