I'm writing a common method which copies two different types of beans which have common fields. I'm using introspection to get the write and read methods, like
propertyDescriptor1.getWriteMethod().invoke(bean1, propertyDescriptor2.getReadMethod().invoke(bean2) )
The above works fine for Strings, but fails for any primitive types like int,long.... Any elegant solutions to copying two different types of beans?
Edit: It's solved, the problem was not with primitive types, I was not checking if the propertyDescriptor.getName() was not "class"