I guess you tried but doed this work ?
private static <U extends ThriftStruct> ThriftStructCodec<U> getCodec(class<U> klass)