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

In the future I think we'll use standard "Java Bean" getters for most classes we expose like this. I think it might be good to add these (`getStageId`, `getPartitionId`). We can keep the current ones for compatiblity (`stageId`) and deprecate them in favor of the new ones.