Snap for 4713750 from f32e187c8566743af6764419192457f63adb0a02 to pi-release
Change-Id: I9ea7a7542dd03078e359aa27f9f0099703a6196d
diff --git a/luni/src/main/java/android/system/Os.java b/luni/src/main/java/android/system/Os.java
index 404b822..6301ff9 100644
--- a/luni/src/main/java/android/system/Os.java
+++ b/luni/src/main/java/android/system/Os.java
@@ -186,17 +186,6 @@
public static int getgid() { return Libcore.os.getgid(); }
/**
- * See <a href="http://man7.org/linux/man-pages/man2/getgroups.2.html">getgroups(2)</a>.
- *
- * <p>Should the number of groups change during the execution of this call, the call may
- * return an arbitrary subset. This may be worth reconsidering should this be exposed
- * as public API.
- *
- * @hide
- */
- public static int[] getgroups() throws ErrnoException { return Libcore.os.getgroups(); }
-
- /**
* See <a href="http://man7.org/linux/man-pages/man3/getenv.3.html">getenv(3)</a>.
*/
public static String getenv(String name) { return Libcore.os.getenv(name); }
@@ -507,13 +496,6 @@
public static void setgid(int gid) throws ErrnoException { Libcore.os.setgid(gid); }
/**
- * See <a href="http://man7.org/linux/man-pages/man2/setgroups.2.html">setgroups(2)</a>.
- *
- * @hide
- */
- public static void setgroups(int[] gids) throws ErrnoException { Libcore.os.setgroups(gids); }
-
- /**
* See <a href="http://man7.org/linux/man-pages/man2/setpgid.2.html">setpgid(2)</a>.
*/
/** @hide */ public static void setpgid(int pid, int pgid) throws ErrnoException { Libcore.os.setpgid(pid, pgid); }
diff --git a/luni/src/main/java/libcore/io/ForwardingOs.java b/luni/src/main/java/libcore/io/ForwardingOs.java
index ce88a3b..f141694 100644
--- a/luni/src/main/java/libcore/io/ForwardingOs.java
+++ b/luni/src/main/java/libcore/io/ForwardingOs.java
@@ -91,7 +91,6 @@
public int getegid() { return os.getegid(); }
public int geteuid() { return os.geteuid(); }
public int getgid() { return os.getgid(); }
- public int[] getgroups() throws ErrnoException { return os.getgroups(); }
public String getenv(String name) { return os.getenv(name); }
public String getnameinfo(InetAddress address, int flags) throws GaiException { return os.getnameinfo(address, flags); }
public SocketAddress getpeername(FileDescriptor fd) throws ErrnoException { return os.getpeername(fd); }
@@ -162,7 +161,6 @@
public void setenv(String name, String value, boolean overwrite) throws ErrnoException { os.setenv(name, value, overwrite); }
public void seteuid(int euid) throws ErrnoException { os.seteuid(euid); }
public void setgid(int gid) throws ErrnoException { os.setgid(gid); }
- public void setgroups(int[] gids) throws ErrnoException { os.setgroups(gids); }
public void setpgid(int pid, int pgid) throws ErrnoException { os.setpgid(pid, pgid); }
public void setregid(int rgid, int egid) throws ErrnoException { os.setregid(rgid, egid); }
public void setreuid(int ruid, int euid) throws ErrnoException { os.setreuid(ruid, euid); }
diff --git a/luni/src/main/java/libcore/io/Linux.java b/luni/src/main/java/libcore/io/Linux.java
index de3b103..807e5a2 100644
--- a/luni/src/main/java/libcore/io/Linux.java
+++ b/luni/src/main/java/libcore/io/Linux.java
@@ -82,7 +82,6 @@
public native int getegid();
public native int geteuid();
public native int getgid();
- public native int[] getgroups() throws ErrnoException;
public native String getenv(String name);
public native String getnameinfo(InetAddress address, int flags) throws GaiException;
public native SocketAddress getpeername(FileDescriptor fd) throws ErrnoException;
@@ -236,7 +235,6 @@
public native void setenv(String name, String value, boolean overwrite) throws ErrnoException;
public native void seteuid(int euid) throws ErrnoException;
public native void setgid(int gid) throws ErrnoException;
- public native void setgroups(int[] gids) throws ErrnoException;
public native void setpgid(int pid, int pgid) throws ErrnoException;
public native void setregid(int rgid, int egid) throws ErrnoException;
public native void setreuid(int ruid, int euid) throws ErrnoException;
diff --git a/luni/src/main/java/libcore/io/Os.java b/luni/src/main/java/libcore/io/Os.java
index 194851f..61584b4 100644
--- a/luni/src/main/java/libcore/io/Os.java
+++ b/luni/src/main/java/libcore/io/Os.java
@@ -76,10 +76,6 @@
public int getegid();
public int geteuid();
public int getgid();
- /* Should the number of groups change during the execution of this call, the call may
- return an arbitrary subset. This may be worth reconsidering should this be exposed
- as public API. */
- public int[] getgroups() throws ErrnoException;
public String getenv(String name);
/* TODO: break into getnameinfoHost and getnameinfoService? */
public String getnameinfo(InetAddress address, int flags) throws GaiException;
@@ -152,7 +148,6 @@
public void setenv(String name, String value, boolean overwrite) throws ErrnoException;
public void seteuid(int euid) throws ErrnoException;
public void setgid(int gid) throws ErrnoException;
- public void setgroups(int[] gids) throws ErrnoException;
public void setpgid(int pid, int pgid) throws ErrnoException;
public void setregid(int rgid, int egid) throws ErrnoException;
public void setreuid(int ruid, int euid) throws ErrnoException;
diff --git a/luni/src/main/native/libcore_io_Linux.cpp b/luni/src/main/native/libcore_io_Linux.cpp
index 04954b9..30da35c 100644
--- a/luni/src/main/native/libcore_io_Linux.cpp
+++ b/luni/src/main/native/libcore_io_Linux.cpp
@@ -19,7 +19,6 @@
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
-#include <grp.h>
#include <ifaddrs.h>
#include <linux/rtnetlink.h>
#include <net/if.h>
@@ -1322,24 +1321,6 @@
return getgid();
}
-static jintArray Linux_getgroups(JNIEnv* env, jobject) {
- int ngrps = throwIfMinusOne(env, "getgroups", getgroups(0, nullptr));
- if (ngrps == -1) {
- return NULL;
- }
- std::vector<gid_t> groups(ngrps, 0);
- ngrps = throwIfMinusOne(env, "getgroups", getgroups(ngrps, &groups[0]));
- if (ngrps == -1) {
- return NULL;
- }
- jintArray out = env->NewIntArray(ngrps);
- if ((out != NULL) && (ngrps > 0)) {
- env->SetIntArrayRegion(out, 0, ngrps, reinterpret_cast<int*>(&groups[0]));
- }
-
- return out;
-}
-
static jstring Linux_getenv(JNIEnv* env, jobject, jstring javaName) {
ScopedUtfChars name(env, javaName);
if (name.c_str() == NULL) {
@@ -2179,13 +2160,6 @@
throwIfMinusOne(env, "setgid", TEMP_FAILURE_RETRY(setgid(gid)));
}
-static void Linux_setgroups(JNIEnv* env, jobject, jintArray gids) {
- size_t ngrps = gids == NULL ? 0 : env->GetArrayLength(gids);
- std::vector<gid_t> groups(ngrps, 0);
- env->GetIntArrayRegion(gids, 0, ngrps, reinterpret_cast<int*>(&groups[0]));
- throwIfMinusOne(env, "setgroups", setgroups(ngrps, &groups[0]));
-}
-
static void Linux_setpgid(JNIEnv* env, jobject, jint pid, int pgid) {
throwIfMinusOne(env, "setpgid", TEMP_FAILURE_RETRY(setpgid(pid, pgid)));
}
@@ -2524,7 +2498,6 @@
NATIVE_METHOD(Linux, getegid, "()I"),
NATIVE_METHOD(Linux, geteuid, "()I"),
NATIVE_METHOD(Linux, getgid, "()I"),
- NATIVE_METHOD(Linux, getgroups, "()[I"),
NATIVE_METHOD(Linux, getenv, "(Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(Linux, getnameinfo, "(Ljava/net/InetAddress;I)Ljava/lang/String;"),
NATIVE_METHOD(Linux, getpeername, "(Ljava/io/FileDescriptor;)Ljava/net/SocketAddress;"),
@@ -2590,7 +2563,6 @@
NATIVE_METHOD(Linux, setenv, "(Ljava/lang/String;Ljava/lang/String;Z)V"),
NATIVE_METHOD(Linux, seteuid, "(I)V"),
NATIVE_METHOD(Linux, setgid, "(I)V"),
- NATIVE_METHOD(Linux, setgroups, "([I)V"),
NATIVE_METHOD(Linux, setpgid, "(II)V"),
NATIVE_METHOD(Linux, setregid, "(II)V"),
NATIVE_METHOD(Linux, setreuid, "(II)V"),
diff --git a/luni/src/test/java/libcore/java/lang/invoke/MethodHandlesTest.java b/luni/src/test/java/libcore/java/lang/invoke/MethodHandlesTest.java
index 9b3850c..fc18ab8 100644
--- a/luni/src/test/java/libcore/java/lang/invoke/MethodHandlesTest.java
+++ b/luni/src/test/java/libcore/java/lang/invoke/MethodHandlesTest.java
@@ -697,7 +697,7 @@
}
public void testUnreflectSpecial_superCalls() throws Throwable {
- Method overridenMethod = UnreflectTester.class.getMethod("overridenMethod");
+ Method overridenMethod = UnreflectTesterBase.class.getMethod("overridenMethod");
UnreflectTester instance = new UnreflectTester("unused");
MethodHandle mh = UnreflectTester.lookup.unreflectSpecial(overridenMethod,
UnreflectTester.class);
diff --git a/luni/src/test/java/libcore/libcore/io/OsTest.java b/luni/src/test/java/libcore/libcore/io/OsTest.java
index f169a2c..ab8f16e 100644
--- a/luni/src/test/java/libcore/libcore/io/OsTest.java
+++ b/luni/src/test/java/libcore/libcore/io/OsTest.java
@@ -926,23 +926,6 @@
return f;
}
- public void test_getgroups() throws Exception {
- int[] gids = Libcore.os.getgroups();
- assertNotNull(gids);
- }
-
- public void test_setgroups() throws Exception {
- final long ngroupsMax = Libcore.os.sysconf(_SC_NGROUPS_MAX);
- final int expectedError = ngroupsMax == 0 ? EINVAL : EPERM;
-
- try {
- Libcore.os.setgroups(new int[] {-1});
- fail();
- } catch (ErrnoException expected) {
- assertEquals(expectedError, expected.errno);
- }
- }
-
public void test_odirect() throws Exception {
File testFile = createTempFile("test_odirect", "");
try {
diff --git a/ojluni/src/main/java/java/net/Inet6AddressImpl.java b/ojluni/src/main/java/java/net/Inet6AddressImpl.java
index cfc2d13..1edfe34 100644
--- a/ojluni/src/main/java/java/net/Inet6AddressImpl.java
+++ b/ojluni/src/main/java/java/net/Inet6AddressImpl.java
@@ -290,9 +290,11 @@
} catch (IOException e) {
// Silently ignore and fall back.
} finally {
- try {
- Libcore.os.close(fd);
- } catch (ErrnoException e) { }
+ if (fd != null) {
+ try {
+ Libcore.os.close(fd);
+ } catch (ErrnoException e) { }
+ }
}
return false;