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

Can you add a warning in the javadoc that explains this should never be called by user programs? It would be nice if this could be `private[spark]` but unfortunately we are in java land :P