Starting with JDK 12, we can obtain the type descriptor of a class as a String object via the Class.descriptorString() method:
// Lmodern/challenge/Pair;
System.out.println("Type descriptor of Pair: "
+ clazz.descriptorString());
// Ljava/lang/String;
System.out.println("Type descriptor of String: "
+ String.class.descriptorString());