-
Notifications
You must be signed in to change notification settings - Fork 552
[nativeaot] introduce Microsoft.Android.Runtime.NativeAOT.dll
#9760
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
af195b0
[nativeaot] introduce `Microsoft.Android.Runtime.NativeAOT.dll`
jonathanpeppers 51f18e4
MVP "typemap" implementation
jonathanpeppers 870d69b
Change namespace to Microsoft.Android.Runtime
jonathanpeppers 579dd2a
`TypeMappings` instance field
jonathanpeppers d989734
JreRuntimeOptions -> NativeAotRuntimeOptions
jonathanpeppers 0aef177
Update IL to read instance field
jonathanpeppers a82417b
How long does InitializeTypeMappings take?
jonpryor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:label="@string/app_name" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"> | ||
<!-- Temporary, to eventually be included in .NET Android infrastructure --> | ||
<provider | ||
android:name="net.dot.jni.nativeaot.NativeAotRuntimeProvider" | ||
android:exported="false" | ||
android:initOrder="1999999999" | ||
android:authorities="net.dot.jni.nativeaot.NativeAotRuntimeProvider.__init__" | ||
/> | ||
</application> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using System.Runtime.Versioning; | ||
|
||
// NOTE: silences the CA1416 analyzer about supported Android APIs | ||
[assembly: TargetPlatformAttribute("Android35.0")] | ||
[assembly: SupportedOSPlatformAttribute("Android21.0")] |
98 changes: 98 additions & 0 deletions
98
src/Microsoft.Android.Runtime.NativeAOT/Java.Interop/JreRuntime.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Originally from: https://github.com/dotnet/java-interop/blob/dd3c1d0514addfe379f050627b3e97493e985da6/src/Java.Runtime.Environment/Java.Interop/JreRuntime.cs | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
using Microsoft.Android.Runtime; | ||
|
||
namespace Java.Interop { | ||
|
||
struct JavaVMInitArgs { | ||
#pragma warning disable CS0649 // Field is never assigned to; | ||
public JniVersion version; /* use JNI_VERSION_1_2 or later */ | ||
|
||
public int nOptions; | ||
public IntPtr /* JavaVMOption[] */ options; | ||
public byte ignoreUnrecognized; | ||
#pragma warning restore CS0649 | ||
} | ||
|
||
class NativeAotRuntimeOptions : JniRuntime.CreationOptions { | ||
|
||
public bool IgnoreUnrecognizedOptions {get; set;} | ||
|
||
public TextWriter? JniGlobalReferenceLogWriter {get; set;} | ||
public TextWriter? JniLocalReferenceLogWriter {get; set;} | ||
|
||
public NativeAotRuntimeOptions () | ||
{ | ||
JniVersion = JniVersion.v1_2; | ||
} | ||
|
||
public JreRuntime CreateJreVM () | ||
{ | ||
return new JreRuntime (this); | ||
} | ||
} | ||
|
||
class JreRuntime : JniRuntime | ||
{ | ||
static JreRuntime () | ||
{ | ||
} | ||
|
||
static NativeAotRuntimeOptions CreateJreVM (NativeAotRuntimeOptions builder) | ||
{ | ||
if (builder == null) | ||
throw new ArgumentNullException ("builder"); | ||
if (builder.InvocationPointer == IntPtr.Zero && | ||
builder.EnvironmentPointer == IntPtr.Zero && | ||
string.IsNullOrEmpty (builder.JvmLibraryPath)) | ||
throw new InvalidOperationException ($"Member `{nameof (NativeAotRuntimeOptions)}.{nameof (NativeAotRuntimeOptions.JvmLibraryPath)}` must be set."); | ||
|
||
#if NET | ||
builder.TypeManager ??= new NativeAotTypeManager (); | ||
#endif // NET | ||
|
||
builder.ValueManager ??= new NativeAotValueManager (builder.TypeManager); | ||
builder.ObjectReferenceManager ??= new ManagedObjectReferenceManager (builder.JniGlobalReferenceLogWriter, builder.JniLocalReferenceLogWriter); | ||
|
||
if (builder.InvocationPointer != IntPtr.Zero || builder.EnvironmentPointer != IntPtr.Zero) | ||
return builder; | ||
|
||
throw new NotImplementedException (); | ||
} | ||
|
||
[UnconditionalSuppressMessage ("Trimming", "IL3000", Justification = "We check for a null Assembly.Location value!")] | ||
internal static string? GetAssemblyLocation (Assembly assembly) | ||
{ | ||
var location = assembly.Location; | ||
if (!string.IsNullOrEmpty (location)) | ||
return location; | ||
return null; | ||
} | ||
|
||
internal protected JreRuntime (NativeAotRuntimeOptions builder) | ||
: base (CreateJreVM (builder)) | ||
{ | ||
} | ||
|
||
public override string? GetCurrentManagedThreadName () | ||
{ | ||
return Thread.CurrentThread.Name; | ||
} | ||
|
||
public override string GetCurrentManagedThreadStackTrace (int skipFrames, bool fNeedFileInfo) | ||
{ | ||
return new StackTrace (skipFrames, fNeedFileInfo) | ||
.ToString (); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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 likewise should be in the static constructor.
Alternatively,
TypeMappings
should be an instance field.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 made it an instance field, as I think it makes more sense for the instance of the
*TypeManager
to hold its typemap.