-
Notifications
You must be signed in to change notification settings - Fork 546
[Mono.Android] add fallback for TypemapManagedToJava
#9811
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Android.Runtime; | ||
|
||
static class RuntimeFeature | ||
{ | ||
const string FeatureSwitchPrefix = "Android.Runtime.RuntimeFeature."; | ||
|
||
[FeatureSwitchDefinition ($"{FeatureSwitchPrefix}{nameof (UseReflectionForManagedToJava)}")] | ||
internal static bool UseReflectionForManagedToJava { get; } = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taking suggestions on a better name than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer that we not need the linker switch, and I think my earlier suggestion would prevent the need for this linker switch. |
||
AppContext.TryGetSwitch ($"{FeatureSwitchPrefix}{nameof (UseReflectionForManagedToJava)}", out bool isEnabled) ? isEnabled : false; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,6 +13,7 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android. | |||||||||
<PropertyGroup> | ||||||||||
<_AndroidRuntimePackRuntime>NativeAOT</_AndroidRuntimePackRuntime> | ||||||||||
<AndroidCodegenTarget Condition=" '$(AndroidCodegenTarget)' == '' ">JavaInterop1</AndroidCodegenTarget> | ||||||||||
<_AndroidUseReflectionForManagedToJava Condition=" '$(_AndroidUseReflectionForManagedToJava)' == '' ">true</_AndroidUseReflectionForManagedToJava> | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be set somewhere where it is not just NativeAOT specific and default to True when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can put the same thing here: Lines 10 to 13 in 66ffd38
If we for sure will need it at first, I can add it. |
||||||||||
<!-- NativeAOT's targets currently gives an error about cross-compilation --> | ||||||||||
<DisableUnsupportedError Condition=" $([MSBuild]::IsOSPlatform('windows')) and '$(DisableUnsupportedError)' == '' ">true</DisableUnsupportedError> | ||||||||||
</PropertyGroup> | ||||||||||
|
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.
I could actually move this check inside
TypemapManagedToJava()
, is that actually better?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.
I think you shouldn't be touching this file at all, because we now have a
NativeAotTypeManager
(7a772f0, 70bd636) and the problem is we're not using it.As suggested on Discord, I think we instead want to update the codepath which is hitting
GetJniName()
/TypemapManagedToJava()
in the first place, by updatingJNIEnv.FindClass()
to call: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.
I'll try this to see if that is even simpler.