Gradle has support for running and building with different JDK versions (it's not new with Gradle 7 but it's a recent feature).
So it was possible to support building Java 16 projects while running Gradle on a supported Java version before Gradle 7 was released.