Uh oh!
There was an error while loading. Please reload this page.
Remove Java.Runtime.Environment and keep Java.Interop tests running - #1447
Conversation
Remove the standalone JRE runtime project and its sample/test consumers from the Java.Interop submodule. This keeps the core Java.Interop build path while dropping the desktop/JRE-oriented runtime pieces that are not needed by the main Android SDK.
There was a problem hiding this comment.
Pull request overview
This PR removes the standalone Java.Runtime.Environment project and its desktop/JRE-oriented test & sample consumers, and updates build/docs metadata to reflect the cleanup and discourage desktop-specific runtime helper usage at the Java.Interop layer.
Changes:
- Removed
src/Java.Runtime.Environmentand all dependent test/sample projects that were built around a standalone desktop/JRE runtime. - Removed JVM-based test suites and performance/overhead benchmarks that depended on the removed runtime path.
- Updated
JniRuntime.GetAvailableInvocationPointers()obsolete guidance, the repoMakefile, and.github/copilot-instructions.mdto align with the new shape.
Show a summary per file
| File | Description |
|---|---|
| tests/TestJVM/TestJVM.csproj | Removed TestJVM helper project (desktop/JRE runtime dependency). |
| tests/TestJVM/TestJVM.cs | Removed TestJVM helper runtime implementation. |
| tests/Java.Interop.Dynamic-Tests/Java.Interop/JavaVMFixture.cs | Removed Dynamic test fixture relying on TestJVM/JRE runtime. |
| tests/Java.Interop.Dynamic-Tests/Java.Interop/DynamicJavaInstanceTests.cs | Removed Dynamic JVM-based test coverage. |
| tests/Java.Interop.Dynamic-Tests/Java.Interop/DynamicJavaClassTests.cs | Removed Dynamic JVM-based test coverage. |
| tests/Java.Interop.Dynamic-Tests/Java.Interop.Dynamic-Tests.csproj | Removed Dynamic test project and its JRE runtime references. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/TestType.java | Removed Java-side test type used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/SelfRegistration.java | Removed Java-side test type used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/RenameClassDerived.java | Removed Java-side test type used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/RenameClassBase2.java | Removed Java-side test type used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/RenameClassBase1.java | Removed Java-side test type used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/RegisterNativesTestType.java | Removed Java-side test type used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/ObjectHelper.java | Removed Java-side helper used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/MyJavaInterfaceImpl.java | Removed Java-side test type used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/JavaInterface.java | Removed Java-side interface used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/GetThis.java | Removed Java-side test type used by JVM-based tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/DesugarAndroidInterface$_CC.java | Removed Java-side desugar test helper. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/CrossReferenceBridge.java | Removed Java-side GC bridge/cross-ref test helper. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/CallVirtualFromConstructorDerived.java | Removed Java-side constructor-virtual-call test helper. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/CallVirtualFromConstructorBase.java | Removed Java-side constructor-virtual-call test helper. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/CallNonvirtualDerived2.java | Removed Java-side nonvirtual dispatch test helper. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/CallNonvirtualDerived.java | Removed Java-side nonvirtual dispatch test helper. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/CallNonvirtualBase.java | Removed Java-side nonvirtual dispatch test helper. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/AnotherJavaInterfaceImpl.java | Removed Java-side interface impl used by tests. |
| tests/Java.Interop-Tests/java/net/dot/jni/test/AndroidInterface.java | Removed Java-side interface used for desugar-related tests. |
| tests/Java.Interop-Tests/Java.Interop/TestTypeTests.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/SelfRegistrationTests.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/SelfRegistration.cs | Removed managed type used by JVM-based tests. |
| tests/Java.Interop-Tests/Java.Interop/MethodBindingTests.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniValueMarshalerAttributeTests.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniTypeSignatureTest.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniTypeSignatureAttributeTest.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniTransitionTest.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniRuntimeTest.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniRuntime.JniValueManagerTests.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniRuntime.JniTypeManagerTests.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniReferenceSafeHandleTest.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniMarshalTests.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniInstanceMethodIDTest.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JniEnvironmentTests.cs | Removed JVM-based unit tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaVMFixture.Partial.cs | Removed JVM fixture scaffolding. |
| tests/Java.Interop-Tests/Java.Interop/JavaVMFixture.cs | Removed JVM fixture setup & type-manager mapping logic. |
| tests/Java.Interop-Tests/Java.Interop/JavaSingleArrayContractTests.cs | Removed JVM-based contract tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaSByteArrayContractTests.cs | Removed JVM-based contract tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaPrimitiveArrayContract.cs | Removed JVM-based contract test base class. |
| tests/Java.Interop-Tests/Java.Interop/JavaPeerableExtensionsTests.cs | Removed JVM-based extension tests and related managed bindings. |
| tests/Java.Interop-Tests/Java.Interop/JavaObjectExtensionsTests.cs | Removed JVM-based extension tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaObjectArrayTest.cs | Removed JVM-based object array contract tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaManagedGCBridgeTests.cs | Removed JVM-based GC bridge tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaInt64ArrayContractTests.cs | Removed JVM-based contract tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaInt32ArrayContractTests.cs | Removed JVM-based contract tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaInt16ArrayContractTests.cs | Removed JVM-based contract tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaExceptionTests.cs | Removed JVM-based exception interop tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaDoubleArrayContractTests.cs | Removed JVM-based contract tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaCharArrayContractTests.cs | Removed JVM-based contract tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaBooleanArrayContractTests.cs | Removed JVM-based contract tests. |
| tests/Java.Interop-Tests/Java.Interop/JavaArrayContract.cs | Removed JVM-based contract test base class. |
| tests/Java.Interop-Tests/Java.Interop/InvokeVirtualFromConstructorTests.cs | Removed JVM-based constructor dispatch tests. |
| tests/Java.Interop-Tests/Java.Interop/GetThis.cs | Removed managed binding used by JVM-based tests. |
| tests/Java.Interop-Tests/Java.Interop/FinalizerHelpers.cs | Removed helper used by JVM-based tests. |
| tests/Java.Interop-Tests/Java.Interop/CallVirtualFromConstructorDerived.cs | Removed managed binding used by JVM-based tests. |
| tests/Java.Interop-Tests/Java.Interop/CallVirtualFromConstructorBase.cs | Removed managed binding used by JVM-based tests. |
| tests/Java.Interop-Tests/Java.Interop/CallNonvirtualDerived2.cs | Removed managed binding used by JVM-based tests. |
| tests/Java.Interop-Tests/Java.Interop/CallNonvirtualDerived.cs | Removed managed binding used by JVM-based tests. |
| tests/Java.Interop-Tests/Java.Interop/CallNonvirtualBase.cs | Removed managed binding used by JVM-based tests. |
| tests/Java.Interop-Tests/Java.Interop-Tests.targets | Removed MSBuild logic for building interop-test.jar and JCWs. |
| tests/Java.Interop-Tests/Java.Interop-Tests.csproj | Removed JVM-based Java.Interop test project. |
| tests/Java.Interop-Tests/Cadenza/BaseRocksFixture.cs | Removed Cadenza test fixture that depended on JavaVMFixture. |
| tests/Java.Interop-Tests/Cadenza.Collections/ListContract.cs | Removed Cadenza collection contract tests. |
| tests/Java.Interop-Tests/Cadenza.Collections/EnumerableContract.cs | Removed Cadenza enumerable contract tests. |
| tests/Java.Interop-PerformanceTests/java/com/xamarin/interop/performance/JavaTiming.java | Removed Java-side performance benchmark fixture. |
| tests/Java.Interop-PerformanceTests/Java.Interop/JavaVMFixture.cs | Removed perf test fixture relying on TestJVM. |
| tests/Java.Interop-PerformanceTests/Java.Interop/JavaPrimitiveArraysTiming.cs | Removed perf tests and benchmark helpers. |
| tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.targets | Removed perf test JAR build target. |
| tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj | Removed performance test project. |
| tests/Java.Base-Tests/java/net/dot/jni/test/PublicInterface.java | Removed Java.Base test Java inputs. |
| tests/Java.Base-Tests/java/net/dot/jni/test/InterfaceMethodInheritance.java | Removed Java.Base test Java inputs. |
| tests/Java.Base-Tests/java/net/dot/jni/test/HasInterfaceMethodInheritance.java | Removed Java.Base test Java inputs. |
| tests/Java.Base-Tests/java/com/microsoft/java_base_tests/Invoker.java | Removed Java.Base test Java inputs. |
| tests/Java.Base-Tests/Java.Base/NestedTypeTests.cs | Removed Java.Base JVM-based tests. |
| tests/Java.Base-Tests/Java.Base/JniRuntimeJniValueManagerContractExtras.cs | Removed Java.Base JVM-based tests. |
| tests/Java.Base-Tests/Java.Base/JavaVMFixture.Partial.cs | Removed Java.Base test fixture scaffolding. |
| tests/Java.Base-Tests/Java.Base/JavaVMFixture.cs | Removed Java.Base fixture setup using TestJVM. |
| tests/Java.Base-Tests/Java.Base/JavaToManagedTests.cs | Removed Java→managed callback tests. |
| tests/Java.Base-Tests/Java.Base/InterfaceMethodInheritanceTests.cs | Removed interface inheritance tests. |
| tests/Java.Base-Tests/Java.Base-Tests.targets | Removed Java.Base test targets. |
| tests/Java.Base-Tests/Java.Base-Tests.csproj | Removed Java.Base test project. |
| tests/invocation-overhead/README.md | Removed standalone invocation-overhead benchmark documentation. |
| tests/invocation-overhead/Makefile | Removed invocation-overhead build helpers. |
| tests/invocation-overhead/invocation-overhead.targets | Removed invocation-overhead MSBuild targets. |
| tests/invocation-overhead/invocation-overhead.csproj | Removed invocation-overhead benchmark project. |
| src/Java.Runtime.Environment/Properties/AssemblyInfo.cs | Removed standalone runtime assembly configuration. |
| src/Java.Runtime.Environment/Java.Runtime.Environment.targets | Removed standalone runtime MSBuild logic. |
| src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config.in | Removed template for dllmap config generation. |
| src/Java.Runtime.Environment/Java.Runtime.Environment.csproj | Removed standalone runtime project. |
| src/Java.Runtime.Environment/Java.Interop/JreTypeManager.cs | Removed JRE-specific type manager implementation. |
| src/Java.Runtime.Environment/.gitignore | Removed ignore entry for generated runtime config. |
| src/Java.Interop/Properties/AssemblyInfo.cs | Removed InternalsVisibleTo entries for deleted assemblies/tests. |
| src/Java.Interop/Java.Interop/JniRuntime.cs | Updated obsolete guidance to avoid referencing removed desktop runtime helpers. |
| samples/Hello-NativeAOTFromJNI/README.md | Removed desktop/JRE-oriented sample docs. |
| samples/Hello-NativeAOTFromJNI/NativeAotTypeManager.cs | Removed NativeAOT-from-JNI sample code. |
| samples/Hello-NativeAOTFromJNI/ManagedType.cs | Removed NativeAOT-from-JNI sample code. |
| samples/Hello-NativeAOTFromJNI/JavaInteropRuntime.cs | Removed NativeAOT-from-JNI sample code. |
| samples/Hello-NativeAOTFromJNI/JavaCallableAttributes.cs | Removed sample-only callable attribute definitions. |
| samples/Hello-NativeAOTFromJNI/java/net/dot/jni/hello/JavaInteropRuntime.java | Removed Java launcher/runtime sample code. |
| samples/Hello-NativeAOTFromJNI/java/net/dot/jni/hello/App.java | Removed Java launcher sample code. |
| samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.targets | Removed sample build targets (JCW + jar). |
| samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.csproj | Removed NativeAOT-from-JNI sample project. |
| samples/Hello-NativeAOTFromJNI/App.cs | Removed sample native entrypoint code. |
| samples/Hello-NativeAOTFromAndroid/Transforms/Metadata.xml | Removed Android NativeAOT sample transform metadata. |
| samples/Hello-NativeAOTFromAndroid/settings.gradle | Removed Android NativeAOT Gradle settings. |
| samples/Hello-NativeAOTFromAndroid/NativeAotTypeManager.cs | Removed Android NativeAOT sample type manager. |
| samples/Hello-NativeAOTFromAndroid/MainActivity.cs | Removed Android NativeAOT managed activity sample. |
| samples/Hello-NativeAOTFromAndroid/LogcatTextWriter.cs | Removed Android NativeAOT logging helper. |
| samples/Hello-NativeAOTFromAndroid/JavaInteropRuntime.cs | Removed Android NativeAOT runtime init code. |
| samples/Hello-NativeAOTFromAndroid/Hello-NativeAOTFromAndroid.csproj | Removed Android NativeAOT sample project. |
| samples/Hello-NativeAOTFromAndroid/gradle.properties | Removed Android NativeAOT sample config. |
| samples/Hello-NativeAOTFromAndroid/build.gradle | Removed Android NativeAOT sample build script. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/res/values/strings.xml | Removed Android sample resources. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml | Removed Android sample resources. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml | Removed Android sample resources. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/res/layout/activity_main.xml | Removed Android sample layout. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/res/drawable/ic_launcher_background.xml | Removed Android sample resources. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/res/drawable-v24/ic_launcher_foreground.xml | Removed Android sample resources. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/java/net/dot/jni/nativeaot/NativeAotRuntimeProvider.java | Removed Android sample Java bootstrapping. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/java/net/dot/jni/nativeaot/JavaMainActivity.java | Removed Android sample Java activity. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/java/net/dot/jni/nativeaot/JavaInteropRuntime.java | Removed Android sample Java runtime loader. |
| samples/Hello-NativeAOTFromAndroid/app/src/main/AndroidManifest.xml | Removed Android sample manifest. |
| samples/Hello-NativeAOTFromAndroid/app/proguard-rules.pro | Removed Android sample ProGuard rules. |
| samples/Hello-NativeAOTFromAndroid/app/build.gradle | Removed Android sample module build script. |
| samples/Hello-NativeAOTFromAndroid/app/.gitignore | Removed Android sample ignores. |
| samples/Hello-NativeAOTFromAndroid/android.xml | Removed Android sample API XML input. |
| samples/Hello-NativeAOTFromAndroid/.gitignore | Removed Android sample ignores. |
| samples/Hello-Java.Base/Program.cs | Removed desktop/JRE-oriented sample program. |
| samples/Hello-Java.Base/Hello-Java.Base.csproj | Removed desktop/JRE-oriented sample project. |
| samples/Hello-Core/README.md | Removed desktop/JRE-oriented sample docs. |
| samples/Hello-Core/Program.cs | Removed desktop/JRE-oriented sample program. |
| samples/Hello-Core/Hello-Core.csproj | Removed desktop/JRE-oriented sample project. |
| Makefile | Updated build metadata, but currently still references removed test outputs (needs further adjustment). |
| .github/copilot-instructions.md | Updated repository guidance to reflect removed runtime/tests and updated validation commands. |
Copilot's findings
- Files reviewed: 162/178 changed files
- Comments generated: 1
Uh oh!
There was an error while loading. Please reload this page.
1723d75 to
58ec716CompareUpdate the Makefile test lists to match the remaining managed test projects and stop building removed desktop/JRE test outputs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
simonrozsival
commented
Jun 8, 2026
@copilot there seem to be many failing tests, so the PR is still not in good shape: |
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
... Fixed in 6fb38a7. I added an explicit |
simonrozsival
commented
Jun 8, 2026
@copilot CI is failing, try to fix it: or |
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Fixed in c39003a. I removed the stale |
simonrozsival
commented
Jun 8, 2026
@copilot explain why we needed to remove these tests. Does it mean that without the full Java.Runtime.Environment, we can't run Java.Interop tests outside of dotnet/android? |
Those tests were removed because they depended on the standalone It does not mean Java.Interop as a whole can only be used with dotnet/android. It means this repo no longer carries the old desktop/JRE-specific runtime host+test harness. The removed test projects specifically exercised that host. To run equivalent runtime tests outside dotnet/android again, we’d need to add and maintain a new supported non-Android host path. |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nvironment Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
…JNI sample Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Updated the branch with latest The trimmable-type-map work made several Validated:
|
simonrozsival
commented
Jun 22, 2026
@copilot fix failing build: |
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
... Fixed in the latest commit. The sample's Validated end-to-end on linux-x64: NativeAOT publish + running The runtime initializes with no exception. |
simonrozsival
commented
Jun 23, 2026
@copilot fix the following build error: |
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
... Fixed in 697b961. The Kotlin/Gradle fixture classes are now generated into each consuming test project's Validated with |
jonathanpeppers
commented
Jun 23, 2026
/review |
✅ Java.Interop PR Reviewer completed successfully! |
There was a problem hiding this comment.
🤖 Code Review — ✅ LGTM (with minor suggestions)
This is a clean, well-executed removal of the Java.Runtime.Environment project. The test-host runtime plumbing it provided (value/object-reference managers, JVM creation) is faithfully re-homed into tests/TestJVM/TestJVM.cs, the NativeAOT sample is made self-contained, and the native build is reworked to a static validation lib. CI is green (build + full Java.Interop test suite pass).
I diffed the ported ManagedValueManager / ManagedObjectReferenceManager against the deleted originals and verified:
- gref/wgref counting is correct (incrementing on a valid result, decrementing on a valid input ref is the right asymmetry);
CreateJVMresource handling is sound —Disposeis idempotent, so theLoadJvmLibrary-throws path doesn't double-free;- the
JavaVMInitArgs/JavaVMOptionstruct layouts (blittable, sequential) and theJNI_CreateJavaVMdelegate* unmanaged<...>signature match the JNI ABI.
I also confirmed there are no dangling references to the removed projects in the solution, Makefile, CI templates, or Sdk.targets, and that Hello-NativeAOTFromJNI (kept) is still exercised via the dedicated dotnet publish CI step rather than the solution.
Findings (non-blocking)
- 💡 Documentation —
tests/TestJVM/TestJVM.cs:478: the "why" comment about theLocal-ref /SafeHandle.ReferenceTypethread-locality invariant was dropped during the port. - 💡 MSBuild —
samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.csproj:41: hardcodedMacOSX15.sdkpath will silently stop applying on future SDKs.
Nice touches
JniRuntimeJniValueManagerContractnow binds the generic<ManagedValueManager>instead ofType.GetType("...Java.Runtime.Environment...")reflection — trimmer/AOT-friendly.src/java-interop/CMakeLists.txtfixes a pre-existingforeach(dir in ${...})syntax bug.Makefilerun-net-testsgains the missing;so every test assembly in the loop actually runs.
Verdict: ✅ LGTM — 0 ❌ · 0
Generated by Java.Interop PR Reviewer for issue #1447 · 2.5K AIC · ⌖ 46.9 AIC · ⊞ 34.6K
Comment /review to run again
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Resolve merge conflicts with main by keeping deletions of: - samples/Hello-NativeAOTFromAndroid/NativeAotTypeManager.cs - samples/Hello-NativeAOTFromJNI/NativeAotTypeManager.cs - src/Java.Runtime.Environment/Java.Interop/JreTypeManager.cs - Address review comments from PR 1447: - Restore the "why" comment on ManagedValueManager.FinalizePeer explaining why we use JniObjectReference.Type instead of SafeHandle.ReferenceType (the latter is thread-local and returns Invalid off-thread for Local refs). - Replace the hard-coded MacOSX15.sdk -isysroot path in Hello-NativeAOTFromJNI.csproj with a target that resolves the macOS SDK dynamically via `xcrun --show-sdk-path`, so it keeps working on newer SDKs and on machines with full Xcode installed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonathanpeppers
commented
Jun 25, 2026
/review |
✅ Java.Interop PR Reviewer completed successfully! |
There was a problem hiding this comment.
🤖 Code Review — Remove Java.Runtime.Environment, keep Java.Interop tests running
Verdict: ✅ Looks good — minor suggestions only (posting as a COMMENT, not an approval).
This is a careful, well-scoped refactor. I read the full tests/TestJVM/TestJVM.cs and diffed the new value/reference managers against the deleted Java.Runtime.Environment originals — the port is faithful. Things I independently verified:
- ✅ The new
CreateJVM/NativeLibraryJvmLibraryHandlerJVM-bootstrap path is correct: theJNI_CreateJavaVMfunction-pointer signature (out IntPtr,out IntPtr,ref JavaVMInitArgs) maps toJavaVM**/void**/void*; marshaled option strings are freed infinally; and the library handle is disposed on every failure path (no double-dispose,LibraryHandlernulled on error). - ✅
JavaVMInitArgs.versionis a 4-byteint-backedJniVersionenum, matchingjint; struct field order matches the JNI layout. - ✅
JDK_OnlySupportsOneVMexpectsNotSupportedException, whichCreateJVMthrows onr != 0; theInvocationPointer-only path correctly short-circuits before creating a second VM. - ✅ Swapping
Type.GetType ("..., Java.Runtime.Environment", throwOnError)forJniRuntimeJniValueManagerContract<ManagedValueManager>removes a reflection/trimming hazard — a nice trimmer/AOT win, and it justifies makingManagedValueManagerpublic. - ✅
App.cs'ssayHellousesJniTransitionwith proper try/catch/finally;JavaInteropRuntime.initintentionally avoidsJniTransition(the runtime isn't initialized yet) and logs instead — both correct. - ✅ Remaining product-code edits (obsolete message text,
InternalsVisibleToremoval, generator/JniPeerMemberscomment cleanup, CMake/targets/Makefile/sln updates) are pure cleanup of references to the deleted assembly.
Issue counts: 0 ❌ · 0
license/cla has completed — the dotnet.java-interop Azure build is still queued, so I can't independently confirm the build/tests pass. The PR description reports 669 passed, 0 failed, 4 skipped locally; please make sure the Azure build goes green before merging.
Note on scope: this PR intentionally removes Java.Base / Java.Runtime.Environment, the samples, and the performance/dynamic test suites, so that coverage goes away by design — the retained Java.Interop-Tests still exercise the core runtime through the rehosted TestJVM.
Thanks for the detailed description and the explicit "kept vs. removed" breakdown — it made reviewing 39k deleted lines tractable. Two small 💡 suggestions inline; nothing blocking.
Generated by Java.Interop PR Reviewer for issue #1447 · 1.7K AIC · ⌖ 49.6 AIC · ⊞ 34.6K
Comment /review to run again
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
XML comments cannot contain --, which broke MSBuild parsing of the csproj on CI. Reword the comment to drop the literal --show-sdk-path`nflag reference so the project loads again. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PR #1481 (merged into main after this PR opened) removed some [DynamicallyAccessedMembers] attributes from the base JniRuntime.JniValueManager abstract methods. After merging main, the sample's overrides still had the old DAM attributes, producing IL2092/IL2095 'overridden members must have the same DynamicallyAccessedMembersAttribute usage' errors when publishing for NativeAOT. Drop DAM from the sample overrides to match the new base signatures: - ActivatePeer (Type type, ...) - GetValueMarshalerCore<T> () - CreateLocalObjectReferenceArgumentCore (Type type, ...) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
The Java.Runtime.Environment project was removed upstream in dotnet/java-interop#1447 (commit 4e142449), so the reference in Xamarin.Android.sln no longer resolves and breaks restore. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
### Bump external/Java.Interop from `8d54473` to `6ec1345` Bumps [external/Java.Interop](https://github.com/dotnet/java-interop) from `8d54473` to `6ec1345`. - [Commits](dotnet/java-interop@8d54473...6ec1345) --- updated-dependencies: - dependency-name: external/Java.Interop dependency-version: 6ec1345165fa7385c935f16ccaa8cc38be50a080 dependency-type: direct:production ... ### Remove Java.Runtime.Environment project from solution The Java.Runtime.Environment project was removed upstream in dotnet/java-interop#1447 (commit 4e142449), so the reference in Xamarin.Android.sln no longer resolves and breaks restore. ### Suppress new IL3050 warnings in ManagedTypeManager Upstream dotnet/java-interop#1474 added [RequiresDynamicCode] to: - JniRuntime.ReflectionJniTypeManager (the class), surfacing IL3050 at ManagedTypeManager..ctor() since we derive from it. - JniEnvironment.Types.RegisterNatives(.., JniNativeMethodRegistration[], int), surfacing IL3050 at ManagedTypeManager.RegisterNativeMembers. Suppress for now; the JniNativeMethodRegistration[] registration path will be migrated to the blittable RegisterNatives(JniObjectReference, ReadOnlySpan<JniNativeMethod>) overload in a future change. Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Related to dotnet/android#11843
Summary
src/Java.Runtime.Environmentproject and the desktop/JRE runtime path it provided.Java.Interop-Testsin the solution and CI, and restore them to a passing state without bringing back theJava.Runtime.Environmentassembly.Java.Runtime.Environmentfriend-assembly dependency fromJava.Interop; keep only theJava.Interop-Testsfriend access needed by the restored tests.src/java-interopdown to the native source subset still consumed by dotnet/android, while keeping a minimal validation project so those sources continue to compile in this repo.Hello-NativeAOTFromJNIsmoke sample that proves Java can load a NativeAOT library, initializeJniRuntimefrom an existingJNIEnv*, and call into a native C# method.Note on
tests/TestJVM/TestJVM.csThis file intentionally grew because it now owns the small amount of JVM-hosting/runtime plumbing that
Java.Interop-Testsstill need after deletingJava.Runtime.Environment.The new code is test-only and replaces the old
TestJVM : JreRuntimedependency with a directTestJVM : JniRuntimehost. It keeps only the pieces needed by the core tests:JNI_CreateJavaVMloading throughNativeLibraryjava-interop.jarandinterop-test.jarJdkInfo.propsor installed JDKsIt deliberately does not reintroduce the old product/runtime API surface such as
JreRuntime,JreRuntimeOptions, Mono runtime managers, standalone runtime packaging, reference-log plumbing, or the nativejava-interopJVM loader path. The restored tests/test host have no remainingJava.Runtime.Environmentreferences.Note on
samples/Hello-NativeAOTFromJNIThe old sample depended on
Java.Runtime.Environment, so this PR restores it as a smaller smoke test instead of bringing back the old sample wholesale.The new sample:
System.loadLibrary("Hello-NativeAOTFromJNI"),JniRuntimefrom the existingJNIEnv*, andsayHello()method that returns a Java string.It does not exercise managed peer construction or generated JCWs; those can be added later with explicit support if we want a broader NativeAOT/JNI sample.
Validation
dotnet build -t:Preparedotnet build src/java-interop/java-interop.csprojdotnet build src/Java.Interop/Java.Interop.csproj --no-restoredotnet build tests/Java.Interop-Tests/Java.Interop-Tests.csproj --no-restoredotnet test tests/Java.Interop-Tests/Java.Interop-Tests.csproj --no-build— 669 passed, 0 failed, 4 skippeddotnet publish -c Release -r osx-arm64 samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.csprojdotnet build -c Release -r osx-arm64 -t:RunJavaSample samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.csproj --no-restore