-
Bug
-
Resolution: Fixed
-
P1
-
5.0
-
None
-
b50
-
generic, x86
-
generic, windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2130419 | 5.0u6 | Peter Zhelezniakov | P1 | Resolved | Fixed | b04 |
The JavaBeans specification states under certain circumstances it is permissible to allow method signatures containing one or more parameters of any arbitrary Java type. But the changes made to EventDescriptor.java in JDK1.5 does not provide support for this.
For example if EventDescriptor is constructed with listener methods array, but the caller doesn't maintain any hard reference to the array. Because EventDescriptor uses soft reference to the listener method array, it may be gced based on memory constraints. In such cases, EventSetDescriptor uses introspector to find listener methods but methods are looked up using the method names array and only methods which takes only one argument is looked for. This will break lots of components whose listener methods have 0 or more than 1 arguments.
If you look into the code in EventSetDescriptor.java
public synchronized Method[] getListenerMethods() {
Method[] methods = getListenerMethods0();
if (methods == null) {
if (listenerMethodDescriptors != null) {
methods = new Method[listenerMethodDescriptors.length];
for (int i = 0; i < methods.length; i++) {
methods[i] = listenerMethodDescriptors[i].getMethod();
}
} else if (listenerMethodNames != null) {
methods = new Method[listenerMethodNames.length];
for (int i = 0; i < methods.length; i++) {
methods[i] = Introspector.findMethod(getListenerType(),
listenerMethodNames[i], 1);
}
}
setListenerMethods(methods);
}
return methods;
}
Note that argument count passed to findMethod is always one.
For example if EventDescriptor is constructed with listener methods array, but the caller doesn't maintain any hard reference to the array. Because EventDescriptor uses soft reference to the listener method array, it may be gced based on memory constraints. In such cases, EventSetDescriptor uses introspector to find listener methods but methods are looked up using the method names array and only methods which takes only one argument is looked for. This will break lots of components whose listener methods have 0 or more than 1 arguments.
If you look into the code in EventSetDescriptor.java
public synchronized Method[] getListenerMethods() {
Method[] methods = getListenerMethods0();
if (methods == null) {
if (listenerMethodDescriptors != null) {
methods = new Method[listenerMethodDescriptors.length];
for (int i = 0; i < methods.length; i++) {
methods[i] = listenerMethodDescriptors[i].getMethod();
}
} else if (listenerMethodNames != null) {
methods = new Method[listenerMethodNames.length];
for (int i = 0; i < methods.length; i++) {
methods[i] = Introspector.findMethod(getListenerType(),
listenerMethodNames[i], 1);
}
}
setListenerMethods(methods);
}
return methods;
}
Note that argument count passed to findMethod is always one.
- backported by
-
JDK-2130419 EventSetDescriptor does not support listener methods taking 0 or more than 1 arguments
- Resolved
- relates to
-
JDK-4809008 Introspector cache should be cleared without explicit flush methods calls
- Resolved
-
JDK-6582164 JavaBeans tests should be open source
- Resolved