Some sun.misc internal APIs are deprectaed in JDK 9 and will be encapsulated or removed in a future release.
/** * Creates a new cleaner. * * @param thunk * The cleanup code to be run when the cleaner is invoked. The * cleanup code is run directly from the reference-handler thread, * so it should be as simple and straightforward as possible. * * @return The new cleaner */ public static Cleaner create(Object ob, Runnable thunk) { if (thunk == null) return null; return add(new Cleaner(ob, thunk)); }