jdk/src/share/classes/java/beans/EventSetDescriptor.java
changeset 5947 0e6f2837eeca
parent 5506 202f599c92aa
child 6657 15dbb366c6a3
equal deleted inserted replaced
5769:2a390122edff 5947:0e6f2837eeca
    25 
    25 
    26 package java.beans;
    26 package java.beans;
    27 
    27 
    28 import java.lang.ref.Reference;
    28 import java.lang.ref.Reference;
    29 import java.lang.reflect.Method;
    29 import java.lang.reflect.Method;
       
    30 import java.lang.reflect.Modifier;
    30 
    31 
    31 /**
    32 /**
    32  * An EventSetDescriptor describes a group of events that a given Java
    33  * An EventSetDescriptor describes a group of events that a given Java
    33  * bean fires.
    34  * bean fires.
    34  * <P>
    35  * <P>
   173 
   174 
   174         setAddListenerMethod(getMethod(sourceClass, addListenerMethodName, 1));
   175         setAddListenerMethod(getMethod(sourceClass, addListenerMethodName, 1));
   175         setRemoveListenerMethod(getMethod(sourceClass, removeListenerMethodName, 1));
   176         setRemoveListenerMethod(getMethod(sourceClass, removeListenerMethodName, 1));
   176 
   177 
   177         // Be more forgiving of not finding the getListener method.
   178         // Be more forgiving of not finding the getListener method.
   178         Method method = Introspector.findMethod(sourceClass,
   179         if (getListenerMethodName != null) {
   179                                                 getListenerMethodName, 0);
   180             setGetListenerMethod(Introspector.findInstanceMethod(sourceClass, getListenerMethodName));
   180         if (method != null) {
       
   181             setGetListenerMethod(method);
       
   182         }
   181         }
   183     }
   182     }
   184 
   183 
   185     private static Method getMethod(Class cls, String name, int args)
   184     private static Method getMethod(Class cls, String name, int args)
   186         throws IntrospectionException {
   185         throws IntrospectionException {
   187         if (name == null) {
   186         if (name == null) {
   188             return null;
   187             return null;
   189         }
   188         }
   190         Method method = Introspector.findMethod(cls, name, args);
   189         Method method = Introspector.findMethod(cls, name, args);
   191         if (method == null) {
   190         if ((method == null) || Modifier.isStatic(method.getModifiers())) {
   192             throw new IntrospectionException("Method not found: " + name +
   191             throw new IntrospectionException("Method not found: " + name +
   193                                              " on class " + cls.getName());
   192                                              " on class " + cls.getName());
   194         }
   193         }
   195         return method;
   194         return method;
   196     }
   195     }