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

ok then we should document clearly that it is not a public api