Skip to content

[native] Remove native Java.Interop support library - #13112

Merged
simonrozsival merged 1 commit into
mainfrom
simonrozsival-remove-native-java-interop
Oct 13, 2026
Merged

simonrozsival merged 1 commit into
mainfrom
simonrozsival-remove-native-java-interop

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

The remaining native Java.Interop symbol lookup wrapper only calls dlsym and allocates an error string. Its unused cross-platform loading helpers are unnecessary for the Android runtimes.

Resolve P/Invoke symbols directly with dlsym/dlerror and report failures through log_errorf, without allocating error strings. Preserve Android-aware library loading and use RTLD_NOW | RTLD_LOCAL explicitly.

Move logging categories into the native runtime, replace the last legacy logging calls, and remove the obsolete sources, solution entries, CMake dependencies, and runtime-pack assets. Incremental builds also remove stale Java.Interop archives.

Local validation

Command Result
make prepare CONFIGURATION=Release Passed
make all CONFIGURATION=Release Passed after generating the additional API-level bindings with BuildExtraApiLevels
./dotnet-local.sh build src/native/native-clr.csproj -c Release --no-restore -v:minimal && ./dotnet-local.sh build src/native/native-nativeaot.csproj -c Release --no-restore -v:minimal Passed for armeabi-v7a, arm64-v8a, and x86_64
JAVA_HOME=$(/usr/libexec/java_home) ./dotnet-local.sh test bin/TestRelease/net11.0/Microsoft.Android.Build.Tasks.Tests.dll --filter FullyQualifiedName~NativeAotSystemPropertiesTests Passed: 2 tests
git diff --cached --check Passed

On an arm64 API 36 emulator, three focused P/Invoke checks passed on each of CoreCLR and NativeAOT, covering library loading, repeated symbol resolution, and a missing entry point followed by a successful native call. The two temporary new tests and their category were removed after validation, as requested; no new tests are included in this PR. Logcat confirmed the standard logger's missing-symbol diagnostic.

A temporary MSBuild harness verified stale-archive cleanup and active-library copying for both runtimes with absolute and relative output paths. Binary inspection confirmed that the removed native API definitions and obsolete runtime-pack archives are absent. The full runtime test suite was not run.


Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed
  • Unit tests

No linked issue. No new unit tests, as requested; local validation is recorded above.

The remaining symbol lookup wrapper only calls dlsym and allocates an
error string.  Its cross-platform loading helpers are unused by the
Android runtimes and do not justify a separate native library.

Resolve P/Invoke symbols directly with dlsym and dlerror, and report
failures through the standard runtime logger.  Keep Android-aware
library loading and use the platform loader flags explicitly.

Move logging categories into the native runtime, replace the last
legacy logging calls, and remove the obsolete sources and build/pack
wiring.  Clean up stale archives during incremental builds.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 09:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes native P/Invoke resolution and runtime-pack contents across multiple runtimes without a full runtime test-suite run.

0 open findings

What changed in this PR

Removes the obsolete native Java.Interop support library, replacing its remaining symbol resolution with direct Android runtime APIs and cleaning associated build and packaging artifacts.

Changes:

  • Resolve P/Invoke symbols directly using dlsym/dlerror.
  • Move native logging categories into the runtime and replace legacy logging calls.
  • Remove obsolete Java.Interop sources, dependencies, assets, and stale archives.
File Description
.github/​copilot-instructions.md Updates native logging guidance.
Microsoft.Android.slnx Removes the obsolete project.
build-tools/​create-packs/​Microsoft.Android.Runtime.proj Stops packaging Java.Interop archives.
build-tools/​debian-metadata/​rules Removes the obsolete module exclusion.
build-tools/​scripts/​java-interop.dllmap Deletes obsolete native mappings.
external/​Java.Interop/​Java.Interop.slnx Removes the native project entry.
external/​Java.Interop/​src/​java-interop/​CMakeLists.txt Deletes validation-library configuration.
external/​Java.Interop/​src/​java-interop/​java-interop-dlfcn.cc Deletes cross-platform loader implementation.
external/​Java.Interop/​src/​java-interop/​java-interop-dlfcn.h Deletes loader declarations.
external/​Java.Interop/​src/​java-interop/​java-interop-logger.h Deletes legacy logging declarations.
external/​Java.Interop/​src/​java-interop/​java-interop-util.cc Deletes platform conversion helpers.
external/​Java.Interop/​src/​java-interop/​java-interop-util.h Deletes legacy utility helpers.
external/​Java.Interop/​src/​java-interop/​java-interop.cc Deletes allocation wrappers.
external/​Java.Interop/​src/​java-interop/​java-interop.csproj Deletes the obsolete native project.
external/​Java.Interop/​src/​java-interop/​java-interop.h Deletes the native API header.
external/​Java.Interop/​src/​java-interop/​java-interop.targets Deletes native validation targets.
src/​Microsoft.Android.Build.Tasks/​Tests/​Microsoft.Android.Build.Tasks.Tests/​NativeAotSystemPropertiesTests.cs Removes the obsolete include path.
src/​Mono.Android/​Android.Runtime/​LogCategories.cs Updates the synchronization reference.
src/​native/​CMakeLists.txt Removes Java.Interop configuration.
src/​native/​clr/​host/​CMakeLists.txt Removes the host link dependency.
src/​native/​clr/​host/​fastdev-assemblies.cc Uses the current logging API.
src/​native/​clr/​host/​host.cc Uses the current logging API.
src/​native/​clr/​include/​host/​pinvoke-override-impl.hh Implements direct symbol resolution.
src/​native/​clr/​include/​runtime-base/​monodroid-dl.hh Removes the wrapper-based symbol lookup.
src/​native/​clr/​runtime-base/​android-system.cc Removes obsolete Java.Interop includes.
src/​native/​clr/​shared/​CMakeLists.txt Removes include and link dependencies.
src/​native/​clr/​shared/​log_functions.cc Removes legacy logger implementations.
src/​native/​common/​include/​shared/​helpers.hh Uses runtime-owned logging categories.
src/​native/​common/​include/​shared/​log_categories.hh Defines native logging categories.
src/​native/​common/​include/​shared/​log_functions.hh Includes the new category header.
src/​native/​common/​java-interop/​CMakeLists.txt Deletes the obsolete static-library target.
src/​native/​native.targets Removes inputs and cleans stale archives.
src/​native/​nativeaot/​host/​CMakeLists.txt Removes the NativeAOT link dependency.

🧠 Review effort: Balanced

@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Oct 13, 2026
@simonrozsival
simonrozsival merged commit e03caec into main Oct 13, 2026
42 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-remove-native-java-interop branch October 13, 2026 13:49
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants