-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2beta2
-
sparc
-
solaris_2.5
-
Verified
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)
======================================================================
======================================================================
- relates to
-
JDK-4908693 REGRESSION: Regression test .../EventSetDescriptor/NullListenerName.java fails
- Closed
-
JDK-6582164 JavaBeans tests should be open source
- Resolved