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

i.e.

```
@Deprecated
/** Deprecated: use getStageId() */
public int stageId() {

}
```