[
https://issues.apache.org/jira/browse/BEANUTILS-281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12512281
]
Henri Yandell commented on BEANUTILS-281:
-----------------------------------------
Interestingly, the Harmony version of Introspector/BeanInfo [which means:
BeanInfoData.java, BeanInfoImpl.java, BeanInfoWrapper.java, Introspector.java]
work correctly.
So we could either view this as a WONTFIX because it's a bug that presumably
will be fixed in 1.7.0; or we could embed the classes above in BeanUtils.
I suspect this bug is too easy to workaround for us to pull in 4 classes from
Harmony. ie:
Change AbstractVehicle to:
public abstract class AbstractVehicle {
public abstract Serializable getField();
public abstract void setField(Serializable s);
}
and add the following method to Car so things compile:
public void setField(java.io.Serializable field) {
setField((Integer) field);
}
Thus I'll close this as WONTFIX.
> BeanUtils.cloneBean and Covariant (Overriding) return types
> -----------------------------------------------------------
>
> Key: BEANUTILS-281
> URL: https://issues.apache.org/jira/browse/BEANUTILS-281
> Project: Commons BeanUtils
> Issue Type: Bug
> Components: Bean / Property Utils
> Environment: JDK1.5
> Reporter: Onur Kutlu GAGO
> Fix For: LATER THAN 1.8.0
>
>
> BeanUtils.cloneBean(Object) method does not copy the fields that are
> overriden by the subclasses. For example, consider an abstract
> class(AbstractVehicle) where you define an abstract getter for a field.
> **************************
> public abstract class AbstractVehicle {
> public abstract Serializable getField();
> }
> ***************************
> In a class (Car) that extends this abstract class (AbstractVehicle) you
> define the field itself and override the return type of the getter method
> (from Serializable to Integer):
> ***************************
> public class Car extends AbstractVehicle {
> private Integer field = null;
> @Override
> public Integer getField() {
> return field;
> }
> public void setField(Integer field) {
> this.field = field;
> }
> }
> ***************************
> When you clone such objects (Car) this field is not copied! The following
> code prints 'null' instead of 5!
> ***************************
> public class CopyTestMain {
> public static void main(String[] args) throws IllegalAccessException,
> InstantiationException, InvocationTargetException, NoSuchMethodException {
> final Car aCar = new Car();
> aCar.setField(5);
> final Car copyCar = (Car) BeanUtils.cloneBean(aCar);
> System.out.println("Field = " + copyCar.getField());
> }
> }
> ***************************
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]