【发布时间】:2016-06-01 10:34:20
【问题描述】:
这里是代码
public class Root {
private Long id;
private List<Child> list;
//getter and setter
}
public class Child {
private Long id;
//getter and setter
}
public static void main(String args) {
Child child = new Child();
child.setId(1L);
List<Child> list = new ArrayList<>();
list.add(child);
Root root = new Root();
Root copyRoot = new Root();
root.setId(2L);
root.setList(list);
BeanCopier copier1 = BeanCopier.create(Root.class, Root.class, false);
copier1.copy(root, copyRoot, null);
//can beancopier in cglib deep copy this root to copyRoot?
//because i found when i used beancopier the two instances still point the same list instance
}
cglib 中的 beancopier 可以深拷贝这个根到 copyRoot 吗? 因为我发现当我使用 beancopier 时,这两个实例仍然指向同一个列表实例
【问题讨论】: