Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ boolean deferVisitVarInsn(int opcode, int var) {
state = State.ALOAD;
return true;
}
if (opcode == ALOAD) {
// maybe constructor initialisation of OneToMany
state = State.ALOAD;
}
return false;
}

Expand Down Expand Up @@ -225,6 +229,10 @@ boolean consumeVisitFieldInsn(int opcode, String owner, String name, String desc
* Return true when a OneToMany or ManyToMany is not initialised in a supported manor.
*/
private boolean unsupportedInitialisation() {
if (state == State.ALOAD) {
// allow constructor initialisation of a OneToMany
return false;
}
return state == State.MAYBE_UNSUPPORTED
|| state == State.UNSET // proceeded by GETSTATIC field bytecode like Collections.EMPTY_LIST
|| state == State.INVOKE_SPECIAL && !isConsumeManyType(); // e.g. new BeanList()
Expand Down
28 changes: 28 additions & 0 deletions test/src/test/java/test/model/ReferencingBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package test.model;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;

import java.util.List;
import java.util.UUID;

@Entity
public class ReferencingBean {

@Id @GeneratedValue
UUID id;

@OneToMany
private List<PBean> rootBeans;

public ReferencingBean(List<PBean> rootBeans) {
this.rootBeans = rootBeans;
}

public List<PBean> getRootBeans() {
return rootBeans;
}

}