realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

RealmList is null in Java17 #7885

Closed ErnestoDavidOlivaPerez closed 2 months ago

ErnestoDavidOlivaPerez commented 2 months ago

How frequently does the bug occur?

Always

Description

I have a two RealmObject's called ParentObject and ChildObject. ParentObject has a RealmList of type ChildObject. When I create a ParentOject and copy it to realm using Realm.createObject(), I expect the returned value to have an empty RealmList of type ChildObject, but I find that field is null. Investigating I looking that this happens when I use Java 17, with Java 11 does not return null.

I don't know why this is happening or if it is a deliberate behaviour. I would like to give answers to these doubts I have. To solve this problem I'm going to check if the RealmList field is null and if it is, create it, at least until I get an answer.

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

To reproduce the error you can change sourceCompatibility and targetCompatibility to Java 17 inside your build.gradle file at module level.

compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
}

Version

10.16.1

What Atlas App Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Android 33

Build environment

No response

sync-by-unito[bot] commented 2 months ago

➤ PM Bot commented:

Jira ticket: RJAVA-1258

ErnestoDavidOlivaPerez commented 2 months ago

The error has been fixed. The next day when I went to find the problem again, I tried to do more test to find a solution or better understand what is happening. But I found that the problem had been solved. The only thing that I think could fix the problem is to clean the project. In any case I close the issue and leave my experience in case anyone needs it.