Index: src/main/java/java/beans/Introspector.java =================================================================== --- src/main/java/java/beans/Introspector.java (revision 549856) +++ src/main/java/java/beans/Introspector.java (working copy) @@ -162,7 +162,6 @@ // ... wrapper = new BeanInfoWrapper(beanInfo, beanInfoImpl); - parent = beanClass.getSuperclass(); if (parent != null && parent != stopClass) { @@ -176,7 +175,7 @@ storeBeanInfoClassInCache(wrapper, beanClass, stopClass, ignoreBeanClassBeanInfo, ignoreSuperClassBeanInfo); - + return wrapper; } Index: src/main/java/java/beans/BeanInfoWrapper.java =================================================================== --- src/main/java/java/beans/BeanInfoWrapper.java (revision 549743) +++ src/main/java/java/beans/BeanInfoWrapper.java (working copy) @@ -35,6 +35,10 @@ private BeanInfoImpl impl; private BeanInfoWrapper parentBeanInfoWrapper; + + private int defaultEventIndex = -1; + + private EventSetDescriptor[] events = null; public BeanInfoWrapper(BeanInfo info, BeanInfoImpl impl) { this.info = info; @@ -151,12 +155,22 @@ public EventSetDescriptor[] getEventSetDescriptors() { EventSetDescriptor[] result = null; EventSetDescriptor[] infoResult = null; + String defaultEventName = null; + if (events != null) { + return events; + } + if (info != null) { BeanInfo[] infos = info.getAdditionalBeanInfo(); + int defIndex = info.getDefaultEventIndex(); infoResult = info.getEventSetDescriptors(); + if (defIndex >= 0 && defIndex < infoResult.length) { + defaultEventName = infoResult[defIndex].getName(); + } + if (infos != null) { for (BeanInfo additionalInfo : infos) { if (infoResult == null) { @@ -171,23 +185,26 @@ if (info == null || infoResult == null) { EventSetDescriptor[] implResult = impl.getEventSetDescriptors(); - + // merge with parent info if (parentBeanInfoWrapper != null) { EventSetDescriptor[] parentResult = parentBeanInfoWrapper .getEventSetDescriptors(); - Map hm = concatArraysUniqueByName( - implResult, parentResult); + Map hm; + Collection values; - Collection values = hm.values(); - int idx = 0; + if (defaultEventName == null) { + int parentDefaultIdx = parentBeanInfoWrapper.getDefaultEventIndex(); + + if (parentDefaultIdx >= 0 && + parentDefaultIdx < parentResult.length) { + defaultEventName = parentResult[parentDefaultIdx].getName(); + } + } - result = new EventSetDescriptor[values.size()]; + hm = concatArraysUniqueByName(implResult, parentResult); + result = hm.values().toArray(new EventSetDescriptor[hm.size()]); - for (FeatureDescriptor fd : values) { - result[idx++] = (EventSetDescriptor) fd; - } - Arrays.sort(result, new Comparator() { public int compare(EventSetDescriptor esd1, EventSetDescriptor esd2) { @@ -206,6 +223,14 @@ result = infoResult; } + if (defaultEventName != null) { + for (int i = 0; i < result.length; i++) { + if (result[i].getName().equals(defaultEventName)) { + defaultEventIndex = i; + } + } + } + return result; } @@ -256,15 +281,12 @@ } public int getDefaultEventIndex() { - int result = -1; - if (info != null) { - result = info.getDefaultEventIndex(); - } else if (parentBeanInfoWrapper != null) { - result = parentBeanInfoWrapper.getDefaultEventIndex(); - } - - return result; + if (events == null) { + events = getEventSetDescriptors(); + } + + return defaultEventIndex; } void setParentToMerge(BeanInfoWrapper parentBeanInfoWrapper) {