I develop a library (JAXX) to generate Swing java file using JavaBean information of Swing widgets, that I am trying to migrate to Java > 9 (See issue).
Using new JavaBean API does not work any longer, since I was using runtime reflection to get information from beans (See JAXXIntrospector class).
private static BeanInfo getExplicitBeanInfo(ClassDescriptor classDescriptor) {
try {
Class<?> beanClass = Class.forName(classDescriptor.getName(), true, classDescriptor.getClassLoader()); // see if there is a class by that name in this package
Method findExplicitBeanInfo = Introspector.class.getDeclaredMethod("findExplicitBeanInfo", Class.class);
findExplicitBeanInfo.setAccessible(true);
return (BeanInfo) findExplicitBeanInfo.invoke(null, beanClass);
} catch (ClassNotFoundException | NoClassDefFoundError e) {
return null; // happens for uncompiled classes
} catch (NoSuchMethodException e) {
throw new RuntimeException("Error: could not find method 'findExplicitBeanInfo' in java.beans.Introspector. You are most likely running a version of Java against which JAXX has not been tested.");
} catch (InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
I try to find how to get now thoses information using Jigsaw but could not find anywhere to to do this with the new API.
How can I get those runtime information now ?
Thanks.
Using the public API (Introspector.getBeanInfo) solve the problem.