Skip to content

Commit b3baae9

Browse files
alexjskicopybara-github
authored andcommitted
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
1 parent 30afc25 commit b3baae9

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/main/java/com/google/devtools/build/lib/unix/ErrnoFileStatus.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ public class ErrnoFileStatus extends FileStatus {
3131
public static final int ELOOP;
3232
public static final int ENOTDIR;
3333
public static final int ENAMETOOLONG;
34+
public static final int ENODATA;
3435

3536
static {
3637
ErrnoConstants constants = ErrnoConstants.getErrnoConstants();
37-
ENOENT = constants.ENOENT;
38-
EACCES = constants.EACCES;
39-
ELOOP = constants.ELOOP;
40-
ENOTDIR = constants.ENOTDIR;
41-
ENAMETOOLONG = constants.ENAMETOOLONG;
38+
ENOENT = constants.errnoENOENT;
39+
EACCES = constants.errnoEACCES;
40+
ELOOP = constants.errnoELOOP;
41+
ENOTDIR = constants.errnoENOTDIR;
42+
ENAMETOOLONG = constants.errnoENAMETOOLONG;
43+
ENODATA = constants.errnoENODATA;
4244
}
4345

4446
/**
@@ -73,11 +75,12 @@ public boolean hasError() {
7375
private static class ErrnoConstants {
7476

7577
// These are set in JNI.
76-
private int ENOENT;
77-
private int EACCES;
78-
private int ELOOP;
79-
private int ENOTDIR;
80-
private int ENAMETOOLONG;
78+
private int errnoENOENT;
79+
private int errnoEACCES;
80+
private int errnoELOOP;
81+
private int errnoENOTDIR;
82+
private int errnoENAMETOOLONG;
83+
private int errnoENODATA;
8184

8285
public static ErrnoConstants getErrnoConstants() {
8386
ErrnoConstants constants = new ErrnoConstants();

src/main/native/unix_jni.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,12 @@ extern "C" JNIEXPORT void JNICALL
384384
Java_com_google_devtools_build_lib_unix_ErrnoFileStatus_00024ErrnoConstants_initErrnoConstants( // NOLINT
385385
JNIEnv *env, jobject errno_constants) {
386386
jclass clazz = env->GetObjectClass(errno_constants);
387-
SetIntField(env, clazz, errno_constants, "ENOENT", ENOENT);
388-
SetIntField(env, clazz, errno_constants, "EACCES", EACCES);
389-
SetIntField(env, clazz, errno_constants, "ELOOP", ELOOP);
390-
SetIntField(env, clazz, errno_constants, "ENOTDIR", ENOTDIR);
391-
SetIntField(env, clazz, errno_constants, "ENAMETOOLONG", ENAMETOOLONG);
387+
SetIntField(env, clazz, errno_constants, "errnoENOENT", ENOENT);
388+
SetIntField(env, clazz, errno_constants, "errnoEACCES", EACCES);
389+
SetIntField(env, clazz, errno_constants, "errnoELOOP", ELOOP);
390+
SetIntField(env, clazz, errno_constants, "errnoENOTDIR", ENOTDIR);
391+
SetIntField(env, clazz, errno_constants, "errnoENAMETOOLONG", ENAMETOOLONG);
392+
SetIntField(env, clazz, errno_constants, "errnoENODATA", ENODATA);
392393
}
393394

394395
namespace {

0 commit comments

Comments
 (0)