Java 找不到sun.nio.ch.FileChannelImpl.read的实现
我正在使用Java 找不到sun.nio.ch.FileChannelImpl.read的实现,java,c,Java,C,我正在使用sun.nio.ch.FileChannelImpl.read在我的java项目的linux环境中读取一个文件,我在我的一个环境中被拒绝了一个权限,该文件对每个人都有读/写/执行权限,但在我的环境中,我们有严格的政策允许使用某些命令,因此我需要了解此方法使用什么命令在我的机器上启用此命令 为了找到该命令,我一直跟踪代码,直到找到其中的一些本机方法 sun.nio.ch.FileDispatcherImpl 方法是 static native int read0(FileDescri
sun.nio.ch.FileChannelImpl.read
在我的java项目的linux环境中读取一个文件,我在我的一个环境中被拒绝了一个权限,该文件对每个人都有读/写/执行权限,但在我的环境中,我们有严格的政策允许使用某些命令,因此我需要了解此方法使用什么命令在我的机器上启用此命令
为了找到该命令,我一直跟踪代码,直到找到其中的一些本机方法
sun.nio.ch.FileDispatcherImpl
方法是
static native int read0(FileDescriptor fd, long address, int len)
throws IOException;
我跟进并找到了显然是用C编写的实现,您可以在下面的示例中找到它
本机实现是
JNIEXPORT jint JNICALL
Java_sun_nio_ch_FileDispatcherImpl_read0(JNIEnv *env, jclass clazz,
jobject fdo, jlong address, jint len)
{
jint fd = fdval(env, fdo);
void *buf = (void *)jlong_to_ptr(address);
return convertReturnVal(env, read(fd, buf, len), JNI_TRUE);
}
现在我需要打开read函数来弄清楚它到底做了什么,但是在包含的头文件之后,我找不到实现,甚至找不到声明该函数的头文件
#include "jni.h"
#include "jni_util.h"
#include "jvm.h"
#include "jlong.h"
#include "sun_nio_ch_FileDispatcherImpl.h"
#include "java_lang_Long.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <unistd.h>
#if defined(__linux__)
#include <linux/fs.h>
#include <sys/ioctl.h>
#endif
#include "nio.h"
#include "nio_util.h"
#包括“jni.h”
#包括“jni_util.h”
#包括“jvm.h”
#包括“jlong.h”
#包括“sun\u nio\u chu FileDispatcherImpl.h”
#包括“java_lang_Long.h”
#包括
#包括
#包括
#包括
#包括
#如果已定义(\uuuu linux\uuuuu)
#包括
#包括
#恩迪夫
#包括“nio.h”
#包括“nio_util.h”
非常感谢您的帮助。read()
是一种从打开的文件描述符读取的方法。它通常由系统libc.so
提供(如果动态链接),或libc.a
提供(如果静态链接)
可以在此处找到一个实现: