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

can u try remove the public modifier and see if it still compiles? I think in that case it defaults to package private, which is the same as the Scala one