Search Issue Tracker




Found in




Issue ID




AndroidJNI.FindClass() always returns IntPtr.Zero when called inside class destructor or finalizer



Reproduction steps:
1. Open the attached project "AndroidJNITests"
2. Build And Run on an Android device
3. Press the “Alloc DummyObject” button
4. Press “Collect GC to trigger DummyObject Finalizer”
5. See the returned output of AndroidJNI.FindClass()

Expected result: Returned value is non-zero
Actual result: Returned value is zero

Reproducible with: 2022.2.0a12, 2022.2.9f1, 2023.1.0b5, 2023.2.0a4
Not reproducible with: 2020.3.46f1, 2021.3.20f1, 2022.2.0a11

Reproducible with devices:
VLNQA00332, Samsung Galaxy XCover4 (SM-G390F), Android 9, CPU: Exynos 7 Quad 7570, GPU: Mali-T720
VLNQA00325, Samsung Galaxy Note10 (SM-N970F), Android 12, CPU: NOT FOUND, GPU: Mali-G76
VLNQA00318, Oneplus OnePlus 7 Pro (GM1913), Android 11, CPU: Snapdragon 855 SM8150, GPU: Adreno (TM) 640
VLNQA00231, Samsung Galaxy A5(2017) (SM-A520F), Android 8.0.0, CPU: Exynos 7 Octa 7880, GPU: Mali-T830
VLNQA00231, Huawei HUAWEI Mate 20 Pro (LYA-L29), Android 9, CPU: HiSilicon Kirin 980, GPU: Mali-G76
iPhone 13 Pro (iOS 15.6.1)

Reproducible on: Windows 10 Enterprise 21H2


* AndroidJNI.FindClass() method in the object's destructor/finalizer always returns an IntPtr.Zero (note that the Java class exists).
It is expected that this method returns the Java class ID
* This works in any other context but in the object's destructor/finalizer
* This bug occurs on Release and Development build

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.