Search in sources :

Example 21 with IntrospectionException

use of java.beans.IntrospectionException in project j2objc by google.

the class IntrospectionExceptionTest method testConstructor.

public void testConstructor() {
    String message = "IntrospectionExceptionTest";
    IntrospectionException e = new IntrospectionException(message);
    assertSame(message, e.getMessage());
}
Also used : IntrospectionException(java.beans.IntrospectionException)

Example 22 with IntrospectionException

use of java.beans.IntrospectionException in project j2objc by google.

the class IntrospectionExceptionTest method testConstructor_MessageNull.

public void testConstructor_MessageNull() {
    IntrospectionException e = new IntrospectionException(null);
    assertNull(e.getMessage());
}
Also used : IntrospectionException(java.beans.IntrospectionException)

Example 23 with IntrospectionException

use of java.beans.IntrospectionException in project j2objc by google.

the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringMethodMethodMethodMethod_propNull.

/*
     * propertyName=null
     */
public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_propNull() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String[].class });
    Method indexedReadMethod = beanClass.getMethod("get" + propertyName, new Class[] { Integer.TYPE });
    Method indexedWriteMethod = beanClass.getMethod("set" + propertyName, new Class[] { Integer.TYPE, String.class });
    try {
        new IndexedPropertyDescriptor(null, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) IntrospectionException(java.beans.IntrospectionException) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) Method(java.lang.reflect.Method)

Example 24 with IntrospectionException

use of java.beans.IntrospectionException in project groovy-core by groovy.

the class MetaClassImpl method addProperties.

private void addProperties() {
    BeanInfo info;
    final Class stopClass;
    //     introspect
    try {
        if (isBeanDerivative(theClass)) {
            info = (BeanInfo) AccessController.doPrivileged(new PrivilegedExceptionAction() {

                public Object run() throws IntrospectionException {
                    return Introspector.getBeanInfo(theClass, Introspector.IGNORE_ALL_BEANINFO);
                }
            });
        } else {
            info = (BeanInfo) AccessController.doPrivileged(new PrivilegedExceptionAction() {

                public Object run() throws IntrospectionException {
                    return Introspector.getBeanInfo(theClass);
                }
            });
        }
    } catch (PrivilegedActionException pae) {
        throw new GroovyRuntimeException("exception during bean introspection", pae.getException());
    }
    PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
    // build up the metaproperties based on the public fields, property descriptors,
    // and the getters and setters
    setupProperties(descriptors);
    EventSetDescriptor[] eventDescriptors = info.getEventSetDescriptors();
    for (EventSetDescriptor descriptor : eventDescriptors) {
        Method[] listenerMethods = descriptor.getListenerMethods();
        for (Method listenerMethod : listenerMethods) {
            final MetaMethod metaMethod = CachedMethod.find(descriptor.getAddListenerMethod());
            // we skip that here
            if (metaMethod == null)
                continue;
            addToAllMethodsIfPublic(metaMethod);
            String name = listenerMethod.getName();
            if (listeners.containsKey(name)) {
                listeners.put(name, AMBIGUOUS_LISTENER_METHOD);
            } else {
                listeners.put(name, metaMethod);
            }
        }
    }
}
Also used : NewInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod) NewMetaMethod(org.codehaus.groovy.runtime.metaclass.NewMetaMethod) MixinInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod) NewStaticMetaMethod(org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod) GeneratedMetaMethod(org.codehaus.groovy.reflection.GeneratedMetaMethod) ClosureMetaMethod(org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod) TransformMetaMethod(org.codehaus.groovy.runtime.metaclass.TransformMetaMethod) PropertyDescriptor(java.beans.PropertyDescriptor) PrivilegedActionException(java.security.PrivilegedActionException) BeanInfo(java.beans.BeanInfo) IntrospectionException(java.beans.IntrospectionException) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) NewInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod) Method(java.lang.reflect.Method) CachedMethod(org.codehaus.groovy.reflection.CachedMethod) NewMetaMethod(org.codehaus.groovy.runtime.metaclass.NewMetaMethod) MixinInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod) NewStaticMetaMethod(org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod) GeneratedMetaMethod(org.codehaus.groovy.reflection.GeneratedMetaMethod) ClosureMetaMethod(org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod) TransformMetaMethod(org.codehaus.groovy.runtime.metaclass.TransformMetaMethod) EventSetDescriptor(java.beans.EventSetDescriptor) CachedClass(org.codehaus.groovy.reflection.CachedClass)

Example 25 with IntrospectionException

use of java.beans.IntrospectionException in project hibernate-orm by hibernate.

the class Cloneable method checkListeners.

private void checkListeners() {
    BeanInfo beanInfo = null;
    try {
        beanInfo = Introspector.getBeanInfo(getClass(), Object.class);
        internalCheckListeners(beanInfo);
    } catch (IntrospectionException t) {
        throw new HibernateException("Unable to validate listener config", t);
    } finally {
        if (beanInfo != null) {
            // release the jdk internal caches everytime to ensure this
            // plays nicely with destroyable class-loaders
            Introspector.flushFromCaches(getClass());
        }
    }
}
Also used : HibernateException(org.hibernate.HibernateException) BeanInfo(java.beans.BeanInfo) IntrospectionException(java.beans.IntrospectionException)

Aggregations

IntrospectionException (java.beans.IntrospectionException)94 PropertyDescriptor (java.beans.PropertyDescriptor)54 BeanInfo (java.beans.BeanInfo)38 Method (java.lang.reflect.Method)38 MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)24 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 HashMap (java.util.HashMap)7 EventSetDescriptor (java.beans.EventSetDescriptor)6 ArrayList (java.util.ArrayList)6 Field (java.lang.reflect.Field)5 RecursiveChildrenListManager (cern.gp.explorer.test.helpers.RecursiveChildrenListManager)3 SimpleDemoBean (cern.gp.explorer.test.helpers.SimpleDemoBean)3 GPNode (cern.gp.nodes.GPNode)3 Map (java.util.Map)3 ResourceBundle (java.util.ResourceBundle)3 TreeExplorer (cern.gp.explorer.TreeExplorer)2 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)2 MethodDescriptor (java.beans.MethodDescriptor)2 SimpleBeanInfo (java.beans.SimpleBeanInfo)2