下面列出了怎么用java.nio.channels.spi.AbstractInterruptibleChannel的API类实例代码及写法,或者点击链接到github查看源代码。
private static void fixChannelMock(AbstractInterruptibleChannel mockFileChannel) throws Exception {
// Note : This is a workaround for NullPointerException.
// This will break when jdk decides to change implementation.
Field closeLockField = AbstractInterruptibleChannel.class.getDeclaredField("closeLock");
closeLockField.setAccessible(true);
closeLockField.set(mockFileChannel, new Object());
}