import java.lang.reflect.*; import java.util.*; import java.util.stream.*; /** * Prints the public methods each named type declares, flagging {@code @Deprecated} ones. * Run it once per classpath (Boot 3.5 and Boot 4) and diff the two files. * Usage: java -cp "$(cat cp.txt)" ApiDump.java org.springframework.data.jpa.repository.JpaRepository ... */ public class ApiDump { public static void main(String[] args) { for (String name : args) { System.out.println("== " + name); try { Class c = Class.forName(name, false, Thread.currentThread().getContextClassLoader()); if (c.isAnnotationPresent(Deprecated.class)) System.out.println(" (type is @Deprecated)"); Arrays.stream(c.getDeclaredMethods()) .filter(m -> Modifier.isPublic(m.getModifiers()) && !m.isSynthetic() && !m.isBridge()) .map(m -> " " + sig(m) + (m.isAnnotationPresent(Deprecated.class) ? " @Deprecated" : "")) .sorted().forEach(System.out::println); } catch (ClassNotFoundException e) { System.out.println(" NOT ON THIS CLASSPATH"); } } } static String sig(Method m) { return (Modifier.isStatic(m.getModifiers()) ? "static " : "") + simple(m.getGenericReturnType()) + " " + m.getName() + "(" + Arrays.stream(m.getGenericParameterTypes()).map(ApiDump::simple).collect(Collectors.joining(", ")) + ")"; } static String simple(Type t) { return t.getTypeName().replaceAll("[a-z][\\w]*\\.", "").replace('$', '.'); } }