private static Rule < ? > createCustomRule ( String javaClass , SoyErrorKind error ) { Class < ? extends Rule < ? > > customRuleClass ; try { @ SuppressWarnings ( "unchecked" ) Class < ? extends Rule < ? > > asSubclass = ( Class < ? extends Rule < ? > > ) Class . forName ( javaClass ) . asSubclass ( Rule . class ) ; customRuleClass = asSubclass ; } catch ( ClassNotFoundException e ) { throw new IllegalArgumentException ( "custom rule class " + javaClass + " not found" , e ) ; } try { // It is ok for the constructor to be non-public as long as it is defined in this package // if it is non public and defined in another package, this will throw an // IllegalAccessException which seems about right. Constructor < ? extends Rule < ? > > ctor = customRuleClass . getDeclaredConstructor ( SoyErrorKind . class ) ; return ctor . newInstance ( error ) ; } catch ( ReflectiveOperationException e ) { throw new IllegalArgumentException ( "unable to construct custom rule class: " + javaClass + ": " + e . getMessage ( ) , e ) ; } }
Instantiates a custom conformance check from its fully - qualified class name specified in the conformance protobuf .