Merge 130a6a8868e932b27953d899736207e069a9de1d on remote branch
Change-Id: I99f249e8322bda9db7fc1f67703c2db1af7a0361
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/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HostnameVerifierTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HostnameVerifierTest.java
index e697838..96384ad 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HostnameVerifierTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HostnameVerifierTest.java
@@ -78,7 +78,7 @@
assertFalse(verifier.verify("a.foo.com", session));
assertTrue(verifier.verify("bar.com", session));
assertFalse(verifier.verify("a.bar.com", session));
- // The certificate has this name in the altnames section, but Conscrypt drops
+ // The certificate has this name in the altnames section, but OkHostnameVerifier drops
// any altnames that are improperly encoded according to RFC 5280, which requires
// non-ASCII characters to be encoded in ASCII via Punycode.
assertFalse(verifier.verify("\u82b1\u5b50.co.jp", session));
@@ -129,11 +129,11 @@
assertFalse(verifier.verify("a.b.foo.com", session));
assertFalse(verifier.verify("bar.com", session));
assertTrue(verifier.verify("www.bar.com", session));
- assertTrue(verifier.verify("\u82b1\u5b50.bar.com", session));
assertFalse(verifier.verify("a.b.bar.com", session));
- // The certificate has this name in the altnames section, but Conscrypt drops
+ // The certificate has this name in the altnames section, but OkHostnameVerifier drops
// any altnames that are improperly encoded according to RFC 5280, which requires
// non-ASCII characters to be encoded in ASCII via Punycode.
+ assertFalse(verifier.verify("\u82b1\u5b50.bar.com", session));
assertFalse(verifier.verify("\u82b1\u5b50.co.jp", session));
assertFalse(verifier.verify("a.\u82b1\u5b50.co.jp", session));
}
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
}