Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6311051

EventSetDescriptor does not support listener methods taking 0 or more than 1 arguments

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P1 P1
    • 6
    • 5.0
    • client-libs
    • None
    • b50
    • generic, x86
    • generic, windows_xp

        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.

              peterz Peter Zhelezniakov
              djayaramsunw Devananda Jayaraman (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: