New posts
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user