Skip to content

JNI DETECTED ERROR IN APPLICATION around accessing boolean fields #10404

Description

@jonpryor

Android framework version

net10.0-android (Preview)

Affected platform version

.NET 10 Preview 6

Description

Bound boolean fields can no longer be used.

Steps to Reproduce

Add the following code to Activity.OnCreate():

var p = new RelativeLayout.LayoutParams(1, 2)
{
    AlignWithParent = true,
};

RelativeLayout.LayoutParams.AlignWithParent binds the Java field RelativeLayout.LayoutParams.alignWithParent

Run the app under .NET 10, e.g. Debug build dotnet build -t:Install,StartAndroidActivity.

App crashes; adb logcat contains:

F droid_boolfiel: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: attempt to access field boolean android.widget.RelativeLayout$LayoutParams.alignWithParent of type boolean with the wrong type byte: 0x709385d8
F droid_boolfiel: java_vm_ext.cc:542]     in call to SetByteField
F droid_boolfiel: java_vm_ext.cc:542]     from void crc6463d68d2626be2acb.MainActivity.n_onCreate(android.os.Bundle)

The cause of the crash is in the binding for AlignWithParent:

	public partial class RelativeLayout : Android.Views.ViewGroup {
		public new partial class LayoutParams : Android.Views.ViewGroup.MarginLayoutParams {

			[Register ("alignWithParent")]
			public bool AlignWithParent {
				get {
					const string __id = "alignWithParent.Z";

					var __v = _members.InstanceFields.GetBooleanValue (__id, this);
					return __v;
				}
				set {
					const string __id = "alignWithParent.Z";

					try {
						_members.InstanceFields.SetValue (__id, this, value ? (sbyte)1 : (sbyte)0);
					} finally {
					}
				}
			}
		}
	}

Specifically, the _members.InstanceFields.SetValue() call provides (sbyte)1 : (sbyte)0 and not true : false.

Did you find any workaround?

No.

Relevant log output

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App RuntimeIssues in `libmonodroid.so`.needs-triageIssues that need to be assigned.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions