[SPARK-3543] Write TaskContext in Java and expose it through a static accessor.

I think it might be better to explicitly set this in the executor when we create the context rather than do it as side effect of construction. What do you think @rxin?