JDK-4072197 : EventSetDescriptor should test for null listenerMethodName string
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 1997-08-15
  • Updated: 1999-01-19
  • Resolved: 1999-01-19
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
1.2.0 1.2beta2Fixed
Related Reports
Relates :  
Relates :  
Description

Name: dsC58869			Date: 08/15/97



EventSetDescriptor(Class,String,Class,String listenerMethodNames[],String,String) 
works wrong when one of the listenerMethodNames elements is null.

It creates an EventSetDescriptor object but a call to 
getListenerMethodDescriptors() results in NullPointerException.

This constructor should either throw a NullPointerException or 
ignore null listenerMethodNames elements.

Other constructors work the same way.

==== Here is the test demonstrating the bug ====
 import java.beans.*;
 import java.lang.reflect.*;
 import java.awt.event.ActionListener;

 class SourceClass {
    public void addActionListener(ActionListener foo) {
    }

    public void removeActionListener(ActionListener foo) {
    }
  }

  class Listener {
    public void action(java.util.EventObject e) {};
    public void event(java.util.EventObject e) {};
    public void dummy(java.util.EventObject e) {};
  }

 public class Test1 {
     public static void main(String[] args){
        Class souceClass = SourceClass.class;
        String eventSetName = "action";
        Class listenerType = Listener.class;
        String listenerMethods[] = {"action","event",null,"dummy"};
        String addListenerMethodName = "addActionListener";
        String removeListenerMethodName = "removeActionListener";
        EventSetDescriptor esd;
	try{ 
          esd = new EventSetDescriptor(souceClass, 
                         eventSetName, listenerType, listenerMethods,
                         addListenerMethodName,removeListenerMethodName);
	} catch (IntrospectionException ie) {
            System.out.println(ie);
            return;
        }
        try{
           MethodDescriptor[] mds = esd.getListenerMethodDescriptors();
        } catch (NullPointerException npe) {
            	npe.printStackTrace();
        }
     }
 }
 
==== Here is the output of the test ====

%java Test1
java.lang.NullPointerException
	at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:39)
	at java.beans.EventSetDescriptor.getListenerMethodDescriptors(EventSetDescriptor.java:217)
	at Test1.main(Test1.java:37)


======================================================================

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2beta INTEGRATED IN: 1.2beta2 VERIFIED IN: 1.2fcs
14-06-2004

EVALUATION Yes, we should change the constructors to check for nulls. KGH 8/16/97 Done. We now throw a NullPointerException from the EventSetDescriptor constructor if one of the listenerMethodNames is null. KGH 9/19/97
11-06-2004