Use reflection to be compatible with we 6.0

Unfortunately it is a compilation problem so just different classes
won't help. But we should still use direct method if they are available
because reflection adds some overhead.