我正在研究snappy、zlib等的压缩器实现(java)。靠近源文件顶部的是下面的这一行。有人能给我解释一下这是什么意思吗?
HACK - Use this as a global lock in the JNI layer
@SuppressWarnings({"unchecked", "unused"})
private static Class clazz = SnappyDecompressor.class;
我知道,例如,在snappy中,snappydecompressor.java本质上是snappyc/本机实现的 Package 器,为了调用该c实现,java层通过jni接口进行调用。
snappy(java Package 器)的源代码snappydecompressor.java的顶部如下:
package org.apache.hadoop.io.compress.snappy;
import java.io.IOException;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.io.compress.Decompressor;
/**
* A {@link Decompressor} based on the snappy compression algorithm.
* http://code.google.com/p/snappy/
*/
public class SnappyDecompressor implements Decompressor {
private static final Log LOG =
LogFactory.getLog(SnappyCompressor.class.getName());
private static final int DEFAULT_DIRECT_BUFFER_SIZE = 64 * 1024;
// HACK - Use this as a global lock in the JNI layer
@SuppressWarnings({"unchecked", "unused"})
private static Class clazz = SnappyDecompressor.class;
完整来源
1条答案
按热度按时间doinxwow1#
如注解所示:它是从jni层使用的,似乎是为了从jni层进行一些锁定(查看完整的解压缩程序(源代码)
第76、77行:
第83行:
第100行至第102行: