In Java the memory allocated by NIO direct buffers is freed with sun.misc.Cleaner
instances, some special phantom references that are more efficient than object finalization.
Is this cleaner mechanism hardcoded in the JVM only for the direct buffer subclasses, or is it possible to also use cleaners in custom components (writing a custom direct byte buffer for instance)?
Here I am not talking about retrieving the cleaner field of an existing nio direct buffer. I am not talking either about manually freeing the memory. This is about writing a new class that allocates direct memory and has it cleaned efficiently and automatically by the garbage collector mechanism.