Skip to content

Bean Introspection problem under IBM Java 1.6 with new ExtendedBeanInfo [SPR-9453] #14088

Closed
@spring-projects-issues

Description

@spring-projects-issues

Friedrich Messner opened SPR-9453 and commented

We're using Spring's BeanWrapper to access a bean via reflection. For one bean's property

  • which has a generic type
  • which is read-only (no setter)
  • whose getter implements an interface

we're getting a org.springframework.beans.NotReadablePropertyException since Spring 3.1. I tracked it a little bit and found out that it is related to the ExtendedBeanInfo class introduced with Spring 3.1. The following example demonstrates this:

package org.springframework.beans;

import static org.junit.Assert.assertEquals;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;

import org.junit.Test;

public class BeanInfoTest {

    public interface Interface<T> {
        T getProp();
    }

    public final class Bean implements Interface<Class<?>> {
        private Class<?> prop;
        public Class<?> getProp() { return prop; }
    }

    @Test
    public void testWithPlainBeanInfo() throws IntrospectionException {
        BeanInfo info = Introspector.getBeanInfo(Bean.class);
        assertEquals(2, info.getPropertyDescriptors().length);
    }

    @Test
    public void testWithExtendedBeanInfo() throws IntrospectionException {
        ExtendedBeanInfo extendedInfo = new ExtendedBeanInfo(
                Introspector.getBeanInfo(Bean.class));
        assertEquals(2, extendedInfo.getPropertyDescriptors().length);
    }
}

While the first test passes, the second fails on IBM JVM 1.6.

If we do any of

  • add a setter
  • remove the interface
  • change the type to non-generic (e.g. String)
  • run it under Sun JVM 1.6

it works.

It seems that ExtendedBeanInfo has a problem with the covariant return types coming from the bridge method for the generic property.


Affects: 3.1.1

Attachments:

Issue Links:

Referenced from: commits b50bb50, 0ee1256, 30d0bd3, 4a8be69

1 votes, 5 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions