< prev index next >

src/java.desktop/share/classes/java/beans/Introspector.java

Print this page




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.beans;
  26 
  27 import com.sun.beans.TypeResolver;
  28 import com.sun.beans.WeakCache;
  29 import com.sun.beans.finder.ClassFinder;
  30 import com.sun.beans.introspect.ClassInfo;
  31 import com.sun.beans.introspect.EventSetInfo;
  32 import com.sun.beans.introspect.PropertyInfo;
  33 
  34 import java.awt.Component;
  35 
  36 import java.lang.ref.Reference;
  37 import java.lang.ref.SoftReference;
  38 import java.lang.reflect.Constructor;

  39 import java.lang.reflect.Method;
  40 import java.lang.reflect.Type;
  41 
  42 import java.util.Map;
  43 import java.util.ArrayList;
  44 import java.util.Arrays;
  45 import java.util.HashMap;
  46 import java.util.Iterator;
  47 import java.util.EventObject;
  48 import java.util.List;
  49 import java.util.TreeMap;
  50 
  51 import jdk.internal.misc.JavaBeansAccess;
  52 import jdk.internal.misc.SharedSecrets;
  53 import sun.reflect.misc.ReflectUtil;
  54 
  55 /**
  56  * The Introspector class provides a standard way for tools to learn about
  57  * the properties, events, and methods supported by a target Java Bean.
  58  * <p>


1263             }
1264             if (b.isInterface()) {
1265                 Class<?>[] interfaces = x.getInterfaces();
1266                 for (int i = 0; i < interfaces.length; i++) {
1267                     if (isSubclass(interfaces[i], b)) {
1268                         return true;
1269                     }
1270                 }
1271             }
1272         }
1273         return false;
1274     }
1275 
1276     /**
1277      * Try to create an instance of a named class.
1278      * First try the classloader of "sibling", then try the system
1279      * classloader then the class loader of the current Thread.
1280      */
1281     static Object instantiate(Class<?> sibling, String className)
1282                  throws InstantiationException, IllegalAccessException,

1283                                                 ClassNotFoundException {
1284         // First check with sibling's classloader (if any).
1285         ClassLoader cl = sibling.getClassLoader();
1286         Class<?> cls = ClassFinder.findClass(className, cl);
1287         return cls.newInstance();
1288     }
1289 
1290 } // end class Introspector
1291 
1292 //===========================================================================
1293 
1294 /**
1295  * Package private implementation support class for Introspector's
1296  * internal use.
1297  * <p>
1298  * Mostly this is used as a placeholder for the descriptors.
1299  */
1300 
1301 class GenericBeanInfo extends SimpleBeanInfo {
1302 
1303     private BeanDescriptor beanDescriptor;
1304     private EventSetDescriptor[] events;
1305     private int defaultEvent;
1306     private PropertyDescriptor[] properties;
1307     private int defaultProperty;




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.beans;
  26 
  27 import com.sun.beans.TypeResolver;
  28 import com.sun.beans.WeakCache;
  29 import com.sun.beans.finder.ClassFinder;
  30 import com.sun.beans.introspect.ClassInfo;
  31 import com.sun.beans.introspect.EventSetInfo;
  32 import com.sun.beans.introspect.PropertyInfo;
  33 
  34 import java.awt.Component;
  35 
  36 import java.lang.ref.Reference;
  37 import java.lang.ref.SoftReference;
  38 import java.lang.reflect.Constructor;
  39 import java.lang.reflect.InvocationTargetException;
  40 import java.lang.reflect.Method;
  41 import java.lang.reflect.Type;
  42 
  43 import java.util.Map;
  44 import java.util.ArrayList;
  45 import java.util.Arrays;
  46 import java.util.HashMap;
  47 import java.util.Iterator;
  48 import java.util.EventObject;
  49 import java.util.List;
  50 import java.util.TreeMap;
  51 
  52 import jdk.internal.misc.JavaBeansAccess;
  53 import jdk.internal.misc.SharedSecrets;
  54 import sun.reflect.misc.ReflectUtil;
  55 
  56 /**
  57  * The Introspector class provides a standard way for tools to learn about
  58  * the properties, events, and methods supported by a target Java Bean.
  59  * <p>


1264             }
1265             if (b.isInterface()) {
1266                 Class<?>[] interfaces = x.getInterfaces();
1267                 for (int i = 0; i < interfaces.length; i++) {
1268                     if (isSubclass(interfaces[i], b)) {
1269                         return true;
1270                     }
1271                 }
1272             }
1273         }
1274         return false;
1275     }
1276 
1277     /**
1278      * Try to create an instance of a named class.
1279      * First try the classloader of "sibling", then try the system
1280      * classloader then the class loader of the current Thread.
1281      */
1282     static Object instantiate(Class<?> sibling, String className)
1283                  throws InstantiationException, IllegalAccessException,
1284                         NoSuchMethodException, InvocationTargetException,
1285                                                 ClassNotFoundException {
1286         // First check with sibling's classloader (if any).
1287         ClassLoader cl = sibling.getClassLoader();
1288         Class<?> cls = ClassFinder.findClass(className, cl);
1289         return cls.getDeclaredConstructor().newInstance();
1290     }
1291 
1292 } // end class Introspector
1293 
1294 //===========================================================================
1295 
1296 /**
1297  * Package private implementation support class for Introspector's
1298  * internal use.
1299  * <p>
1300  * Mostly this is used as a placeholder for the descriptors.
1301  */
1302 
1303 class GenericBeanInfo extends SimpleBeanInfo {
1304 
1305     private BeanDescriptor beanDescriptor;
1306     private EventSetDescriptor[] events;
1307     private int defaultEvent;
1308     private PropertyDescriptor[] properties;
1309     private int defaultProperty;


< prev index next >