dotnet / dotnet/android

Reduce Java.Interop to the components required by dotnet/android

Open
#11,843 0 comments 0 reactions 0 assignees View on GitHub
java-interop needs-triage
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 21h
Merged PRs (30d)
257

Description

## Goal

Reduce this repository to the minimum set of components that are required by `dotnet/android`, and remove legacy standalone JVM/desktop experiments, samples, tests, and alternative runtime paths that are no longer maintained or used by the Android SDK product path.

This should be done incrementally across multiple focused PRs rather than as one large deletion PR.

## Current understanding

`dotnet/android` still uses several Java.Interop components directly:

- `src/Java.Interop/Java.Interop.csproj` is referenced by `src/Mono.Android/Mono.Android.csproj` as the core managed JNI runtime.
- `external/Java.Interop/tools/generator/generator.csproj` is referenced by `src/Mono.Android/Mono.Android.csproj`, and `src/Mono.Android/Mono.Android.targets` invokes `generator.dll` with `--codegen-target=XAJavaInterop1` to generate the `Mono.Android` binding sources.
- `external/Java.Interop/tools/class-parse/class-parse.csproj` and `external/Java.Interop/tools/param-name-importer/param-name-importer.csproj` are referenced by `build-tools/create-android-api/create-android-api.csproj` to generate Android API profile XML from `android.jar` and source parameter metadata.
- `external/Java.Interop/tools/jcw-gen/jcw-gen.csproj` and `external/Java.Interop/tools/java-source-utils/java-source-utils.csproj` are referenced by `src/Mono.Android/Mono.Android.csproj`.
- The Android SDK pack explicitly includes `class-parse.dll` and `generator.dll` under `tools`.
- Customer binding projects use the .NET for Android MSBuild targets/tasks, but those tasks still default to `class-parse.dll` and `generator.dll` for Java binding generation.

There are also dotnet/android-specific tools around this flow:

- `build-tools/create-android-api` orchestrates Android API profile generation.
- `build-tools/api-xml-adjuster` and `build-tools/api-merge` post-process and merge API XML.
- `src/Xamarin.Android.Build.Tasks` provides the MSBuild task wrappers and SDK integration.

So the Java.Interop tools are still used, but not every historical component in this repo appears to be required by the dotnet/android product path.

## Cleanup candidates

The first cleanup candidate is already being handled separately:

- Remove `Java.Runtime.Environment` and its direct desktop/JRE sample and test consumers.

Potential follow-up candidates to investigate and remove if proven unused by dotnet/android:

- `Java.Interop.Dynamic`
- `Java.Interop.GenericMarshaler`
- `Java.Base` and `src/Java.Base-ref.cs` if they are only useful for standalone Java.Interop scenarios and not required by dotnet/android
- standalone JVM/desktop samples
- tests that only validate removed standalone scenarios
- old native/JVM glue paths that are not used by dotnet/android and are not needed to validate remaining supported components
- Maven/Javadoc/source utility pieces only if dotnet/android no longer depends on them through the API or binding generation flow

## Proposed approach

For each component:

1. Prove whether `dotnet/android` references or packages it.
2. Remove the component in a small PR if unused.
3. Update solution/build metadata and docs in the same PR.
4. Validate the remaining Java.Interop build and relevant dotnet/android build/test path.
5. Keep components that are part of the Android API or binding generation path until a replacement/removal plan exists.

## Initial keep list

Based on current dotnet/android wiring, these should be considered required unless further investigation proves otherwise:

- `src/Java.Interop`
- `tools/generator` and `src/Java.Interop.Tools.Generator`
- `tools/class-parse`
- `tools/param-name-importer`
- `tools/jcw-gen`
- `tools/java-source-utils`
- `src/Java.Interop.Tools.JavaCallableWrappers`
- `src/Java.Interop.Tools.JavaTypeSystem`
- `src/Java.Interop.Tools.TypeNameMappings`
- `src/Java.Interop.Tools.Cecil`
- `src/Xamarin.Android.Tools.ApiXmlAdjuster`
- `src/Xamarin.Android.Tools.Bytecode`
- `src/Xamarin.SourceWriter`
- shared diagnostics/localization support used by the above

## Notes

Recent Android API binding work follows this pipeline:

- `build-tools/create-android-api` runs Java.Interop `class-parse` over platform `android.jar` and uses parameter metadata to generate `src/Mono.Android/Profiles/api-*.xml` inputs.
- `api-xml-adjuster` and `api-merge` shape/merge those XML files.
- `src/Mono.Android/Mono.Android.targets` invokes Java.Interop `generator.dll` with `--codegen-target=XAJavaInterop1` to generate the managed `Mono.Android` binding sources.

This means the goal is not to remove all Java.Interop tooling, but to remove the historical standalone runtime/sample/experimental pieces that are no longer part of the dotnet/android-supported surface.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.