handle builtin and token sorts more generally in the java backend