JNIEXPORT jint JNICALL setFd(
JNIEnv *env, jobject obj, jobject socket) {
JNIEnv e = *env;
jclass clazz;
jfieldID fid;
jobject impl;
jobject fdesc;
/* get the SocketImpl from the Socket */
if (!(clazz = e->GetObjectClass(env, socket))
|| !(fid = e->GetFieldID(env, clazz, "impl",
"Ljava/net/SocketImpl;"))
|| !(impl = e->GetObjectField(env, socket, fid)))
return -1;
/* get the FileDescriptor from the SocketImpl */
if (!(clazz = e->GetObjectClass(env, impl))
|| !(fid = e->GetFieldID(env, clazz, "fd",
"Ljava/io/FileDescriptor;"))
|| !(fdesc = e->GetObjectField(env, impl, fid)))
return -1;
/* get the fd from the FileDescriptor */
if (!(clazz = e->GetObjectClass(env, fdesc))
|| !(