Discuss / Java / 报错 Unhandled exception: java.beans.IntrospectionException,似乎需要加异常处理

报错 Unhandled exception: java.beans.IntrospectionException,似乎需要加异常处理

Topic source

花间的酒

#1 Created at ... [Delete] [Delete and Lock User]

getBeanInfo似乎一定会抛出一个 IntrospectionException,不处理的话会报错

public static BeanInfo getBeanInfo(Class<?> beanClass)    throws IntrospectionException{    if (!ReflectUtil.isPackageAccessible(beanClass)) {        return (new Introspector(beanClass, null, USE_ALL_BEANINFO)).getBeanInfo();    }    ThreadGroupContext context = ThreadGroupContext.getContext();    BeanInfo beanInfo = context.getBeanInfo(beanClass);    if (beanInfo == null) {        beanInfo = new Introspector(beanClass, null, USE_ALL_BEANINFO).getBeanInfo();        context.putBeanInfo(beanClass, beanInfo);    }    return beanInfo;}

public static void main(String[] args) throws IntrospectionException {

}

这个示例代码在main里面把错误抛出了,如果出现异常程序之间停了,但是可以通过编译


  • 1

Reply