JDK-6311051 : EventSetDescriptor does not support listener methods taking 0 or more than 1 arguments
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 5.0
  • Priority: P1
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2005-08-15
  • Updated: 2012-10-10
  • Resolved: 2005-08-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u6Fixed 6 b50Fixed
Related Reports
Relates :  
Relates :  
Description
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.

Comments
SUGGESTED FIX Webrev link: http://sa.sfbay.sun.com/projects/swing_data//mustang/6311051
22-08-2005

EVALUATION This appears to have regressed with the fix to 4809008.
15-08-2005

SUGGESTED FIX One possible solution is to have an integer array which keeps the number of arguments for listener methods along with the String array which keeps the name of listener methods. Both of these arrays can be used when the listener method array reference is no longer valid
15-08-2005