Here you can find the source of callCleaner(ByteBuffer byteBuffer)
Parameter | Description |
---|---|
byteBuffer | byte buffer to be "Garbage Collected" |
Parameter | Description |
---|---|
NoSuchMethodException | an exception |
InvocationTargetException | an exception |
IllegalAccessException | an exception |
public static void callCleaner(ByteBuffer byteBuffer) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
//package com.java2s; //License from project: Open Source License import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.ByteBuffer; public class Main { /**//from w w w . j a v a2 s . c o m * Perform "GC" of byte buffer * @param byteBuffer byte buffer to be "Garbage Collected" * @throws NoSuchMethodException * @throws InvocationTargetException * @throws IllegalAccessException */ public static void callCleaner(ByteBuffer byteBuffer) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method cleanerMethod = byteBuffer.getClass().getMethod("cleaner"); cleanerMethod.setAccessible(true); Object cleaner = cleanerMethod.invoke(byteBuffer); Method cleanMethod = cleaner.getClass().getMethod("clean"); cleanMethod.setAccessible(true); cleanMethod.invoke(cleaner); } }