I’m using PropertyUtils.copyProperties() to copy an object’s properties via reflection, and it used to work well. Recently however, it started not doing anything.
It doesn’t throw an exception, but just will not copy any fields. All the fields of the target object remains null, although there are non-null fields in the source objects.
I don’t know how to reproduce this. For me, it happens consistently, but it’s inside a project that I can’t just publish here. The project uses Play Framework, that does some bytecode manipulation, so that might be the culprit.
Any advice or ideas on what could be causing this, or how to debug? Alternative field-copiers I can try are also welcome (I tried BeanUtils once before, but switched to PropertyUtils because of some caveat I don’t remember by now).
I think I figured it out. It happened to me today. I was just donig some small test with it, and it didn’t work. Here’s the code:
It solved this making the classes public. Maybe one of your classes isn’t public. Here’s the solution in my case: