It's a very complex way of creating this expression, why not use createExpression("$" + fieldName)?
Almost the same would work for createClassLabel, which BTW has nothing to do with classes and simply creates a label.