/**
* @since 2.7.2
*/
protected AST createUsingCtor(Token token, String className) {
Class c = null;
AST t = null;
try {
c = Class.forName(className);
Class[] tokenArgType = new Class[] { persistence.antlr.Token.class };
try {
Constructor ctor = c.getConstructor(tokenArgType);
t = (AST)ctor.newInstance(new Object[]{token}); // make a new one
}
catch (NoSuchMethodException e){
// just do the regular thing if you can't find the ctor
// Your AST must have default ctor to use this.
t = create(c);
if ( t!=null ) {
t.initialize(token);
}
}
}
catch (Exception e) {
throw new IllegalArgumentException("Invalid class or can't make instance, "+className);