From b3baae9720653a9c6fa8d97780d59331bd590e23 Mon Sep 17 00:00:00 2001 From: ajurkowski Date: Wed, 16 Feb 2022 17:38:31 -0800 Subject: [PATCH] Add a constant to `ErrnoFileStatus` for `ENODATA` initialized from JNI. Rename the intermediate variables used to propagate errno from JNI to conform to the naming style. PiperOrigin-RevId: 429181816 --- .../build/lib/unix/ErrnoFileStatus.java | 23 +++++++++++-------- src/main/native/unix_jni.cc | 11 +++++---- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/unix/ErrnoFileStatus.java b/src/main/java/com/google/devtools/build/lib/unix/ErrnoFileStatus.java index 936d94f2c3ae7d..f208ac78187cb0 100644 --- a/src/main/java/com/google/devtools/build/lib/unix/ErrnoFileStatus.java +++ b/src/main/java/com/google/devtools/build/lib/unix/ErrnoFileStatus.java @@ -31,14 +31,16 @@ public class ErrnoFileStatus extends FileStatus { public static final int ELOOP; public static final int ENOTDIR; public static final int ENAMETOOLONG; + public static final int ENODATA; static { ErrnoConstants constants = ErrnoConstants.getErrnoConstants(); - ENOENT = constants.ENOENT; - EACCES = constants.EACCES; - ELOOP = constants.ELOOP; - ENOTDIR = constants.ENOTDIR; - ENAMETOOLONG = constants.ENAMETOOLONG; + ENOENT = constants.errnoENOENT; + EACCES = constants.errnoEACCES; + ELOOP = constants.errnoELOOP; + ENOTDIR = constants.errnoENOTDIR; + ENAMETOOLONG = constants.errnoENAMETOOLONG; + ENODATA = constants.errnoENODATA; } /** @@ -73,11 +75,12 @@ public boolean hasError() { private static class ErrnoConstants { // These are set in JNI. - private int ENOENT; - private int EACCES; - private int ELOOP; - private int ENOTDIR; - private int ENAMETOOLONG; + private int errnoENOENT; + private int errnoEACCES; + private int errnoELOOP; + private int errnoENOTDIR; + private int errnoENAMETOOLONG; + private int errnoENODATA; public static ErrnoConstants getErrnoConstants() { ErrnoConstants constants = new ErrnoConstants(); diff --git a/src/main/native/unix_jni.cc b/src/main/native/unix_jni.cc index 6264b992ddadc9..a51cbb6627b8c9 100644 --- a/src/main/native/unix_jni.cc +++ b/src/main/native/unix_jni.cc @@ -384,11 +384,12 @@ extern "C" JNIEXPORT void JNICALL Java_com_google_devtools_build_lib_unix_ErrnoFileStatus_00024ErrnoConstants_initErrnoConstants( // NOLINT JNIEnv *env, jobject errno_constants) { jclass clazz = env->GetObjectClass(errno_constants); - SetIntField(env, clazz, errno_constants, "ENOENT", ENOENT); - SetIntField(env, clazz, errno_constants, "EACCES", EACCES); - SetIntField(env, clazz, errno_constants, "ELOOP", ELOOP); - SetIntField(env, clazz, errno_constants, "ENOTDIR", ENOTDIR); - SetIntField(env, clazz, errno_constants, "ENAMETOOLONG", ENAMETOOLONG); + SetIntField(env, clazz, errno_constants, "errnoENOENT", ENOENT); + SetIntField(env, clazz, errno_constants, "errnoEACCES", EACCES); + SetIntField(env, clazz, errno_constants, "errnoELOOP", ELOOP); + SetIntField(env, clazz, errno_constants, "errnoENOTDIR", ENOTDIR); + SetIntField(env, clazz, errno_constants, "errnoENAMETOOLONG", ENAMETOOLONG); + SetIntField(env, clazz, errno_constants, "errnoENODATA", ENODATA); } namespace {