private static MetaBean metaBeanLookup ( Class < ? > cls ) { // handle dynamic beans if ( cls == FlexiBean . class ) { return new FlexiBean ( ) . metaBean ( ) ; } else if ( cls == MapBean . class ) { return new MapBean ( ) . metaBean ( ) ; } else if ( DynamicBean . class . isAssignableFrom ( cls ) ) { try { return cls . asSubclass ( DynamicBean . class ) . getDeclaredConstructor ( ) . newInstance ( ) . metaBean ( ) ; } catch ( NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException ex ) { throw new IllegalArgumentException ( "Unable to find meta-bean for a DynamicBean: " + cls . getName ( ) , ex ) ; } } // a Class can be loaded without being initialized // in this state, the static initializers have not run, and thus the metabean not registered // here initialization is forced to handle that scenario try { cls = Class . forName ( cls . getName ( ) , true , cls . getClassLoader ( ) ) ; } catch ( ClassNotFoundException | Error ex ) { // should be impossible throw new IllegalArgumentException ( "Unable to find meta-bean: " + cls . getName ( ) , ex ) ; } MetaBean meta = META_BEANS . get ( cls ) ; if ( meta == null ) { throw new IllegalArgumentException ( "Unable to find meta-bean: " + cls . getName ( ) ) ; } return meta ; }
lookup the MetaBean outside the fast path aiding hotspot inlining