-
Notifications
You must be signed in to change notification settings - Fork 565
[java-runtime] simplify mono.MonoPackageManager.LoadApplication()
#9655
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
Conversation
We currently have code that loads `MonoRuntimeProvider.Bundled.java`
and parses Java code comments between:
// Mono Runtime Initialization {{{
android.content.pm.ApplicationInfo applicationInfo = context.getApplicationInfo ();
String[] apks = null;
String[] splitApks = applicationInfo.splitSourceDirs;
if (splitApks != null && splitApks.length > 0) {
apks = new String[splitApks.length + 1];
apks [0] = applicationInfo.sourceDir;
System.arraycopy (splitApks, 0, apks, 1, splitApks.length);
} else {
apks = new String[] { applicationInfo.sourceDir };
}
mono.MonoPackageManager.LoadApplication (context, applicationInfo, apks);
// }}}
These lines are used for any `Instrumentation` type, such as:
https://github.com/dotnet/java-interop/blob/2c06b3c2a11833aea0e9b51aac2a72195bd64539/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers.CallableWrapperMembers/CallableWrapperType.cs#L238-L241
To refactor and cleanup, we can:
* Make `mono.MonoPackageManager.LoadApplication()` only take in a
single `Context context` parameter.
* Move the Java code that looks at `applicationInfo.splitSourceDirs`
inside `mono.MonoPackageManager.LoadApplication()`.
* Reduce the code in the `// Mono Runtime Initialization {{{` block to
a single line.
* Now we no longer need to load the `MonoRuntimeProvider.Bundled.java`
file during a build, we can simply declare the one line of Java code
as a C# string.
This will make refactoring `<GenerateJavaStubs/>` easier in future PRs.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| static android.content.Context Context; | ||
|
|
||
| public static void LoadApplication (Context context, ApplicationInfo runtimePackage, String[] apks) | ||
| public static void LoadApplication (Context context) |
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 API is "internal" and fine to change parameters?
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.
It should be "internal", in that "nobody other than us" should be invoking it…
If nobody hits it in .NET 10 previews, it's fine! 🤪
This comment was marked as outdated.
This comment was marked as outdated.
* main: Add `$(Nullable)` = `annotations` to projects using NRT annotations without NRT enabled. (#9660) [Xamarin.Android.Build.Tasks] Add %(NuGetPackage*) to TaskItems (#9559) Bump to dotnet/java-interop@ee47652d (#9659) [XABT] Remove <CollectAssemblyFilesForArchive/> from FastDeployment (#9650) [Mono.Android] Generate API docs for API level 35 (#9647) [java-runtime] simplify `mono.MonoPackageManager.LoadApplication()` (#9655) [Mono.Android] Bind Android API-Baklava DP2. (#9653) [build+macOS] Remove quarantine from OpenJDK installations (#9652)
* dev/grendel/use-libc++: Add `$(Nullable)` = `annotations` to projects using NRT annotations without NRT enabled. (#9660) [Xamarin.Android.Build.Tasks] Add %(NuGetPackage*) to TaskItems (#9559) Bump to dotnet/java-interop@ee47652d (#9659) [XABT] Remove <CollectAssemblyFilesForArchive/> from FastDeployment (#9650) [Mono.Android] Generate API docs for API level 35 (#9647) [java-runtime] simplify `mono.MonoPackageManager.LoadApplication()` (#9655) [Mono.Android] Bind Android API-Baklava DP2. (#9653) [build+macOS] Remove quarantine from OpenJDK installations (#9652)
We currently have code that loads
MonoRuntimeProvider.Bundled.javaand parses Java code comments between:These lines are used for any
Instrumentationtype, such as:https://github.com/dotnet/java-interop/blob/2c06b3c2a11833aea0e9b51aac2a72195bd64539/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers.CallableWrapperMembers/CallableWrapperType.cs#L238-L241
To refactor and cleanup, we can:
Make
mono.MonoPackageManager.LoadApplication()only take in a singleContext contextparameter.Move the Java code that looks at
applicationInfo.splitSourceDirsinsidemono.MonoPackageManager.LoadApplication().Reduce the code in the
// Mono Runtime Initialization {{{block to a single line.Now we no longer need to load the
MonoRuntimeProvider.Bundled.javafile during a build, we can simply declare the one line of Java code as a C# string.This will make refactoring
<GenerateJavaStubs/>easier in future PRs.