Snap for 7077657 from af0cb26a2f106a036639d3d7ee025f93b4967538 to r-keystone-qcom-release
Change-Id: I37e9fa0203aa81fd24b7c62993105f2e03d58396
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index 0d98122..8b0ab3b 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -406,6 +406,9 @@
":openjdk_lambda_stub_files",
":openjdk_lambda_duplicate_stub_files",
],
+ // This jar is packaged as part of the SDK, use -target 8 so that it works
+ // with old JDKs.
+ java_version: "1.8",
}
// An alternative to core-lambda-stubs that omits openjdk_lambda_duplicate_stub_files
diff --git a/luni/src/test/java/libcore/java/io/RandomAccessFileTest.java b/luni/src/test/java/libcore/java/io/RandomAccessFileTest.java
index 3811cbc..eab558a 100644
--- a/luni/src/test/java/libcore/java/io/RandomAccessFileTest.java
+++ b/luni/src/test/java/libcore/java/io/RandomAccessFileTest.java
@@ -41,16 +41,6 @@
file.delete();
}
- public void testSeekTooLarge() throws Exception {
- try (RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
- try {
- raf.seek(Long.MAX_VALUE);
- fail();
- } catch (IOException expected) {
- }
- }
- }
-
public void testSetLengthTooLarge() throws Exception {
try (RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
try {
diff --git a/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java b/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
index f0f79ad..8375421 100644
--- a/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
+++ b/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
@@ -17,6 +17,7 @@
package libcore.java.net;
import junit.framework.TestCase;
+import org.mockito.Mockito;
import android.system.StructIfaddrs;
import java.io.BufferedReader;
@@ -39,6 +40,7 @@
import java.util.regex.Pattern;
import libcore.io.IoUtils;
import libcore.io.Libcore;
+import libcore.io.Os;
import static android.system.OsConstants.AF_INET;
import static android.system.OsConstants.IFF_LOOPBACK;
@@ -48,6 +50,7 @@
import static android.system.OsConstants.IFF_UP;
import static android.system.OsConstants.SOCK_DGRAM;
import static java.net.NetworkInterface.getNetworkInterfaces;
+import static org.mockito.ArgumentMatchers.anyString;
public class NetworkInterfaceTest extends TestCase {
// http://code.google.com/p/android/issues/detail?id=13784
@@ -221,6 +224,29 @@
assertEquals(ifaddrsNames, actualNiNames);
}
+ // Validate that we don't fail to enumerate interfaces if there is virtual interface without parent interface present.
+ // b/159277702
+ public void testGetNetworkInterfaces_OrphanInterfaceDoesNotThrow() throws Exception {
+ Os originalOs = Libcore.getOs();
+ Os mockOs = Mockito.mock(Os.class);
+
+ try {
+ Mockito.when(mockOs.getifaddrs()).thenReturn(new StructIfaddrs[] {
+ new StructIfaddrs("dummy0:1", 0, null, null, null, null),
+ });
+
+ Mockito.when(mockOs.if_nametoindex(anyString())).thenReturn(1);
+
+ assertTrue("Failed to swap OS implementation", Libcore.compareAndSetOs(originalOs, mockOs));
+
+ Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
+ assertEquals(1, Collections.list(interfaces).size());
+ }
+ finally {
+ assertTrue("Failed to revert OS implementation", Libcore.compareAndSetOs(mockOs, originalOs));
+ }
+ }
+
// Calling getSubInterfaces on interfaces with no subinterface should not throw NPE.
// http://b/33844501
public void testGetSubInterfaces() throws Exception {
diff --git a/ojluni/src/main/java/java/net/NetworkInterface.java b/ojluni/src/main/java/java/net/NetworkInterface.java
index a30b6bf..e56e0cb 100644
--- a/ojluni/src/main/java/java/net/NetworkInterface.java
+++ b/ojluni/src/main/java/java/net/NetworkInterface.java
@@ -494,8 +494,11 @@
NetworkInterface parent = nis.get(parentName);
ni.virtual = true;
- ni.parent = parent;
- parent.childs.add(ni);
+
+ if (parent != null) {
+ ni.parent = parent;
+ parent.childs.add(ni);
+ }
}
}
diff --git a/ojluni/src/main/native/zip_util.c b/ojluni/src/main/native/zip_util.c
index 6c02d2b..aa9c5ce 100644
--- a/ojluni/src/main/native/zip_util.c
+++ b/ojluni/src/main/native/zip_util.c
@@ -156,7 +156,7 @@
* JVM_IO_INTR is tricky and could cause undesired side effect. So we decided
* to simply call "read" on Solaris/Linux. See details in bug 6304463.
*/
- return pread(zfd, buf, nbytes, offset);
+ return pread64(zfd, buf, nbytes, offset);
#endif
}