Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-415

Read method returned for a generic method overridden in a subclass is inconsistent between java 1.6 and 1.7

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • 2.0.0
    • Bean / Property Utils
    • None
    • Linux/maven

    Description

      The test below passes when run under java 1.7, but fails under java 1.6. I feel the behaviour should be consistent between the two. I will provide more details if there is any difficulty reproducing.

      import static org.fest.assertions.Assertions.assertThat;
      import java.beans.PropertyDescriptor;
      import java.util.Arrays;
      import org.apache.commons.beanutils.PropertyUtils;
      import org.junit.Test;
      import com.google.common.base.Predicate;
      import com.google.common.collect.Iterables;

      public class PropertyUtilsTest {
      public static class Superclass<S> {
      private S property;
      public S getProperty()

      { return property; }

      }

      public static class Subclass extends Superclass<String> {
      @Override
      public String getProperty()

      { return super.getProperty(); }

      }

      @Test
      public void usesSubclassAccessorMethod() throws Exception {
      final PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(PropertyUtilsTest.Subclass.class);
      final PropertyDescriptor descriptor = Iterables.find(Arrays.asList(descriptors), new Predicate<PropertyDescriptor>() {

      @Override
      public boolean apply(final PropertyDescriptor input)

      { return "property".equals(input.getName()); }

      });
      assertThat(descriptor.getReadMethod()).isEqualTo(Subclass.class.getMethod("getProperty")).isNotEqualTo(Superclass.class.getMethod("getProperty"));
      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            michaeld Michael Donaghy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: