3909N/A * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * The Introspector class provides a standard way for tools to learn about 0N/A * the properties, events, and methods supported by a target Java Bean. 0N/A * For each of those three kinds of information, the Introspector will 0N/A * separately analyze the bean's class and superclasses looking for 0N/A * either explicit or implicit information and use that information to 0N/A * build a BeanInfo object that comprehensively describes the target bean. 0N/A * For each class "Foo", explicit information may be available if there exists 0N/A * a corresponding "FooBeanInfo" class that provides a non-null value when 0N/A * queried for the information. We first look for the BeanInfo class by 0N/A * taking the full package-qualified name of the target bean class and 0N/A * appending "BeanInfo" to form a new class name. If this fails, then 0N/A * we take the final classname component of this name, and look for that 0N/A * class in each of the packages specified in the BeanInfo package search 0N/A * Thus for a class such as "sun.xyz.OurButton" we would first look for a 0N/A * BeanInfo class called "sun.xyz.OurButtonBeanInfo" and if that failed we'd 0N/A * look in each package in the BeanInfo search path for an OurButtonBeanInfo 0N/A * class. With the default search path, this would mean looking for 0N/A * "sun.beans.infos.OurButtonBeanInfo". 0N/A * If a class provides explicit BeanInfo about itself then we add that to 0N/A * the BeanInfo information we obtained from analyzing any derived classes, 0N/A * but we regard the explicit information as being definitive for the current 0N/A * class and its base classes, and do not proceed any further up the superclass 0N/A * If we don't find explicit BeanInfo on a class, we use low-level 0N/A * reflection to study the methods of the class and apply standard design 0N/A * patterns to identify property accessors, event sources, or public 0N/A * methods. We then proceed to analyze the class's superclass and add 0N/A * in the information from it (and possibly on up the superclass chain). 0N/A * For more information about introspection and design patterns, please 0N/A // Flags that can be used to control getBeanInfo: 0N/A // Static Caches to speed up introspection. 0N/A // These should be removed. 0N/A // Methods maps from Method objects to MethodDescriptors 0N/A // properties maps from String names to PropertyDescriptors 0N/A // events maps from String names to EventSetDescriptors 0N/A //====================================================================== 0N/A //====================================================================== 0N/A * Introspect on a Java Bean and learn about all its properties, exposed 0N/A * methods, and events. 0N/A * If the BeanInfo class for a Java Bean has been previously Introspected 0N/A * then the BeanInfo class is retrieved from the BeanInfo cache. 0N/A * @param beanClass The bean class to be analyzed. 0N/A * @return A BeanInfo object describing the target bean. 0N/A * @exception IntrospectionException if an exception occurs during 0N/A * @see #flushFromCaches 0N/A * Introspect on a Java bean and learn about all its properties, exposed 0N/A * methods, and events, subject to some control flags. 0N/A * If the BeanInfo class for a Java Bean has been previously Introspected 0N/A * based on the same arguments then the BeanInfo class is retrieved 0N/A * from the BeanInfo cache. 0N/A * @param beanClass The bean class to be analyzed. 0N/A * @param flags Flags to control the introspection. 0N/A * If flags == USE_ALL_BEANINFO then we use all of the BeanInfo 0N/A * classes we can discover. 0N/A * If flags == IGNORE_IMMEDIATE_BEANINFO then we ignore any 0N/A * BeanInfo associated with the specified beanClass. 0N/A * If flags == IGNORE_ALL_BEANINFO then we ignore all BeanInfo 0N/A * associated with the specified beanClass or any of its 0N/A * @return A BeanInfo object describing the target bean. 0N/A * @exception IntrospectionException if an exception occurs during 0N/A * Introspect on a Java bean and learn all about its properties, exposed 0N/A * methods, below a given "stop" point. 0N/A * If the BeanInfo class for a Java Bean has been previously Introspected 0N/A * based on the same arguments, then the BeanInfo class is retrieved 0N/A * from the BeanInfo cache. 0N/A * @param beanClass The bean class to be analyzed. 0N/A * @param stopClass The baseclass at which to stop the analysis. Any 0N/A * will be ignored in the analysis. 0N/A * @exception IntrospectionException if an exception occurs during 0N/A * Introspect on a Java Bean and learn about all its properties, 0N/A * exposed methods and events, below a given {@code stopClass} point 0N/A * subject to some control {@code flags}. 0N/A * <dt>USE_ALL_BEANINFO</dt> 0N/A * <dd>Any BeanInfo that can be discovered will be used.</dd> 0N/A * <dt>IGNORE_IMMEDIATE_BEANINFO</dt> 0N/A * <dd>Any BeanInfo associated with the specified {@code beanClass} will be ignored.</dd> 0N/A * <dt>IGNORE_ALL_BEANINFO</dt> 0N/A * <dd>Any BeanInfo associated with the specified {@code beanClass} 0N/A * or any of its parent classes will be ignored.</dd> 0N/A * or in its parent classes will be ignored in the analysis. 0N/A * If the BeanInfo class for a Java Bean has been 0N/A * previously introspected based on the same arguments then 0N/A * the BeanInfo class is retrieved from the BeanInfo cache. 0N/A * @param beanClass the bean class to be analyzed 0N/A * @param stopClass the parent class at which to stop the analysis 0N/A * @param flags flags to control the introspection 0N/A * @return a BeanInfo object describing the target bean 0N/A * @exception IntrospectionException if an exception occurs during introspection 0N/A // Same parameters to take advantage of caching. 0N/A // Old behaviour: Make an independent copy of the BeanInfo. 0N/A //return new GenericBeanInfo(bi); 0N/A * Utility method to take a string and convert it to normal Java variable 0N/A * name capitalization. This normally means converting the first 0N/A * character from upper case to lower case, but in the (unusual) special 0N/A * case when there is more than one character and both the first and 0N/A * second characters are upper case, we leave it alone. 0N/A * Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays 0N/A * @param name The string to be decapitalized. 0N/A * @return The decapitalized version of the string. 0N/A * Gets the list of package names that will be used for 0N/A * finding BeanInfo classes. 0N/A * @return The array of package names that will be searched in 0N/A * order to find BeanInfo classes. The default value 0N/A * for this array is implementation-dependent; e.g. 0N/A * Sun implementation initially sets to {"sun.beans.infos"}. 0N/A * Change the list of package names that will be used for 0N/A * finding BeanInfo classes. The behaviour of 0N/A * this method is undefined if parameter path 0N/A * <p>First, if there is a security manager, its <code>checkPropertiesAccess</code> 0N/A * method is called. This could result in a SecurityException. 0N/A * @param path Array of package names. 0N/A * @exception SecurityException if a security manager exists and its 0N/A * <code>checkPropertiesAccess</code> method doesn't allow setting 0N/A * of system properties. 0N/A * @see SecurityManager#checkPropertiesAccess 0N/A * Flush all of the Introspector's internal caches. This method is 0N/A * not normally required. It is normally only needed by advanced 0N/A * tools that update existing "Class" objects in-place and need 0N/A * to make the Introspector re-analyze existing Class objects. 0N/A * Flush the Introspector's internal cached information for a given class. 0N/A * This method is not normally required. It is normally only needed 0N/A * by advanced tools that update existing "Class" objects in-place 0N/A * and need to make the Introspector re-analyze an existing Class object. 0N/A * Note that only the direct state associated with the target Class 0N/A * object is flushed. We do not flush state for other Class objects 0N/A * with the same name, nor do we flush state for any related Class 0N/A * objects (such as subclasses), even though their state may include 0N/A * information indirectly obtained from the target Class object. 0N/A * @param clz Class object to be flushed. 0N/A * @throws NullPointerException If the Class object is null. 0N/A //====================================================================== 0N/A // Private implementation methods 0N/A //====================================================================== 0N/A // Check stopClass is a superClass of startClass. 0N/A * Constructs a GenericBeanInfo class from the state of the Introspector 0N/A // the evaluation order here is import, as we evaluate the 0N/A // event sets and locate PropertyChangeListeners before we 0N/A // look for properties. 0N/A * Looks for an explicit BeanInfo class that corresponds to the Class. 0N/A * First it looks in the existing package that the Class is defined in, 0N/A * then it checks to see if the class is its own BeanInfo. Finally, 0N/A * the BeanInfo search path is prepended to the class and searched. 1405N/A * @param beanClass the class type of the bean 0N/A * @return Instance of an explicit BeanInfo class or null if one isn't found. 0N/A * @return An array of PropertyDescriptors describing the editable 0N/A * properties supported by the target bean. 0N/A // Check if the bean has its own BeanInfo that will provide 0N/A // explicit information. 0N/A // We have no explicit BeanInfo properties. Check with our parent. 0N/A // Add the explicit BeanInfo data to our results. 0N/A // Apply some reflection to the current class. 0N/A // First get an array of all the public methods at this level 0N/A // Now analyze each method. 0N/A // skip static methods. 0N/A // Optimization. Don't bother with invalid propertyNames. 0N/A // This happens if a PropertyDescriptor or IndexedPropertyDescriptor 0N/A // constructor fins that the method violates details of the deisgn 0N/A // pattern, e.g. by having an empty name, or a getter returning 0N/A // void , or whatever. 0N/A // If this class or one of its base classes is a PropertyChange 0N/A // source, then we assume that any properties we discover are "bound". 0N/A // Allocate and populate the result array. 0N/A // Set the default index. 0N/A * Adds the property descriptor to the list store. 0N/A // replace existing property descriptor 0N/A // only if we have types to resolve 0N/A // in the context of this.beanClass 0N/A * Populates the property descriptor table by merging the 0N/A * lists of Property descriptors. 0N/A // First pass. Find the latest getter method. Merge properties 0N/A // of previous getter methods. 0N/A // Don't replace the existing read 0N/A // method if it starts with "is" 0N/A // Second pass. Find the latest setter method which 0N/A // has the same type as the getter method. 0N/A // At this stage we should have either PDs or IPDs for the 0N/A // representative getters and setters. The order at which the 0N/A // property descriptors are determined represent the 0N/A // precedence of the property ordering. 0N/A // Complete indexed properties set 0N/A // Merge any classic property descriptors 0N/A // Complete simple properties set 0N/A // Merge any classic property descriptors 0N/A // Merge any classic property descriptors 0N/A // Very special case to ensure that an IndexedPropertyDescriptor 0N/A // doesn't contain less information than the enclosed 0N/A // PropertyDescriptor. If it does, then recreate as a 0N/A // PropertyDescriptor. See 4168833 0N/A // Find the first property descriptor 0N/A // which does not have getter and setter methods. 0N/A // See regression bug 4984912. 0N/A * Adds the property descriptor to the indexedproperty descriptor only if the 0N/A * types are the same. 0N/A * The most specific property descriptor will take precedence. 0N/A // Cannot merge the pd because of type mismatch 0N/A // Return the most specific pd 0N/A // Try to add methods which may have been lost in the type change 0N/A // no consequences for failure. 0N/A // no consequences for failure. 0N/A // Handle regular pd merge 0N/A // Handle regular ipd merge 0N/A * @return An array of EventSetDescriptors describing the kinds of 0N/A * events fired by the target bean. 0N/A // Check if the bean has its own BeanInfo that will provide 0N/A // explicit information. 0N/A // We have no explicit BeanInfo events. Check with our parent. 0N/A // Add the explicit explicitBeanInfo data to our results. 0N/A // Apply some reflection to the current class. 0N/A // Get an array of all the public beans methods at this level 0N/A // Find all suitable "add", "remove" and "get" Listener methods 0N/A // The name of the listener type is the key for these hashtables 0N/A // i.e, ActionListener 0N/A // skip static methods. 0N/A // Optimization avoid getParameterTypes 0N/A // Now look for matching addFooListener+removeFooListener pairs. 0N/A // Bonus if there is a matching getFooListeners method as well. 0N/A // Skip any "add" which doesn't have a matching "remove" or 0N/A // a listener name that doesn't end with Listener 0N/A // generate a list of Method objects for each of the target methods: 0N/A // If the adder method throws the TooManyListenersException then it 0N/A // is a Unicast event source. 0N/A }
// if (adds != null ... 0N/A // Allocate and populate the result array. 0N/A // Set the default index. 0N/A * @return An array of MethodDescriptors describing the private 0N/A * methods supported by the target bean. 0N/A // Check if the bean has its own BeanInfo that will provide 0N/A // explicit information. 0N/A // We have no explicit BeanInfo methods. Check with our parent. 0N/A // Add the explicit explicitBeanInfo data to our results. 0N/A // Apply some reflection to the current class. 0N/A // First get an array of all the beans methods at this level 0N/A // Now analyze each method. 0N/A // Allocate and populate the result array. 0N/A // We have to be careful here to distinguish method by both name 0N/A // and argument lists. 0N/A // This method gets called a *lot, so we try to be efficient. 0N/A // This is the common case. 0N/A // We have a collision on method names. This is rare. 0N/A // Check if old and md have the same type. 0N/A // We have a collision on method names with different type signatures. 0N/A // This is very rare. 0N/A * Creates a key for a method in a method cache. 0N/A // Use explicit info, if available, 0N/A // OK, fabricate a default BeanDescriptor. 3083N/A // Each customizer should inherit java.awt.Component and implement java.beans.Customizer 3731N/A // according to the section 9.3 of JavaBeans™ specification 0N/A // We assume that a method is an event handler if it has a single 0N/A // argument, whose type inherit from java.util.Event. 0N/A * Internal method to return *public* methods within a class. 0N/A // Looking up Class.getDeclaredMethods is relatively expensive, 0N/A // so we cache the results. 0N/A //====================================================================== 0N/A // Package private support methods. 0N/A //====================================================================== 2788N/A * Internal support for finding a target methodName with a given 2788N/A * parameter list on a given class. 2788N/A // For overriden methods we need to find the most derived version. 2788N/A // So we start with the given class and walk up the superclass chain. 2788N/A // make sure method signature matches. 2788N/A // Now check any inherited interfaces. This is necessary both when 2788N/A // the argument class is itself an interface, and when the argument 2788N/A // class is an abstract class. 2788N/A // Note: The original implementation had both methods calling 2788N/A // the 3 arg method. This is preserved but perhaps it should 2788N/A // pass the args array instead of null. 2788N/A * Find a target methodName on a given class. 2788N/A * Find a target methodName with specific parameter list on a given class. 2788N/A * Used in the contructors of the EventSetDescriptor, 2788N/A * PropertyDescriptor and the IndexedPropertyDescriptor. 2788N/A * @param cls The Class object on which to retrieve the method. 2788N/A * @param methodName Name of the method. 2788N/A * @param argCount Number of arguments for the desired method. 2788N/A * @param args Array of argument types for the method. 2788N/A * @return the method or null if not found 0N/A * Return true if class a is either equivalent to class b, or 0N/A * if class a is a subclass of class b, i.e. if a either "extends" 0N/A * or "implements" b. 0N/A * Note tht either or both "Class" objects may represent interfaces. 0N/A // We rely on the fact that for any given java class or 0N/A // primtitive type there is a unqiue Class object, so 0N/A // we can use object equivalence in the comparisons. 0N/A * Return true iff the given method throws the given exception. 0N/A * Try to create an instance of a named class. 0N/A * First try the classloader of "sibling", then try the system 0N/A * classloader then the class loader of the current Thread. 0N/A // First check with sibling's classloader (if any). 0N/A}
// end class Introspector 0N/A//=========================================================================== 0N/A * Package private implementation support class for Introspector's 0N/A * Mostly this is used as a placeholder for the descriptors. 0N/A * Package-private dup constructor 0N/A * This must isolate the new object from any changes to the old object. 0N/A for (
int i =
0; i <
len; i++) {
0N/A for (
int i =
0; i <
len; i++) {
0N/A for (
int i =
0; i <
len; i++) {