New posts

This commit is contained in:
2026-11-06 21:43:48 +05:30
parent ecceaa8b32
commit f7b6c1efca
33 changed files with 1258 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
/** Asks the running JDK which public sun.misc.Unsafe methods are deprecated for removal. Run: java tools/ListUnsafe.java */
public class ListUnsafe {
public static void main(String[] args) throws Exception {
List<String> kept = new ArrayList<>();
int removal = 0, total = 0;
for (Method m : Class.forName("sun.misc.Unsafe").getDeclaredMethods()) {
if (!Modifier.isPublic(m.getModifiers())) continue;
total++;
Deprecated d = m.getAnnotation(Deprecated.class);
if (d != null && d.forRemoval()) removal++;
else kept.add(m.getName() + (d != null ? " (deprecated, not for removal)" : ""));
}
Collections.sort(kept);
System.out.println("java.version=" + System.getProperty("java.version"));
System.out.println("public methods declared by sun.misc.Unsafe: " + total);
System.out.println("deprecated for removal: " + removal);
System.out.println("not deprecated for removal: " + kept.size());
kept.forEach(k -> System.out.println(" " + k));
}
}