}
try {
Object result = constructor.newInstance(callArgs);
return result;
} catch (InstantiationException e) {
throw new ExecuteException("NewExpression.interpret : unable to instantiate class " + typeName + getPos(), e);
} catch (IllegalAccessException e) {
throw new ExecuteException("NewExpression.interpret : unable to access class " + typeName + getPos(), e);
} catch (InvocationTargetException e) {
throw new ExecuteException("NewExpression.interpret : unable to invoke constructor for class " + typeName + getPos(), e);
}
} else {
int[] dims = new int[arrayDimDefinedCount];
Type componentType = type;
for (int i = 0; i < arrayDimDefinedCount; i++) {
Expression dim = arrayDims.get(i);
int dimValue = (Integer)dim.interpret(helper);
dims[i] = dimValue;
componentType = componentType.getBaseType();
}
try {
Object result = Array.newInstance(componentType.getTargetClass(), dims);
return result;
} catch (IllegalArgumentException e) {
throw new ExecuteException("NewExpression.interpret : unable to instantiate array " + typeName + getPos(), e);
} catch (NegativeArraySizeException e) {
// should never happen
throw new ExecuteException("NewExpression.interpret : unable to instantiate array " + typeName + getPos(), e);
}
}
}