History log of /libcore/luni/src/main/java/java/net/InetAddress.java
Revision Date Author Comments
8ffa0b68c9fd3f722bee2bcd94b1d38151a0791d 13-May-2013 Elliott Hughes <enh@google.com> Un-@hide various APIs.

Bug: 3484927
Change-Id: I4cda326a31240135d883528d9cb976a9db084234
75cf14944d476670f6f915e5efd849e238a16250 16-Feb-2012 Elliott Hughes <enh@google.com> Throw SecurityException for DNS without INTERNET permission.

When GoogleTV had to work around this for glibc, I realized that maybe I was
the problem, not the C library...

Bug: http://code.google.com/p/android/issues/detail?id=15722
Change-Id: Ia3fbf2f4578ad60d84e538819660c181248f1e1c
afd70b773bd938c845a3bb0d9a3e21ec64d4db1a 07-Feb-2012 Elliott Hughes <enh@google.com> Rely more on the C library level DNS caching.

This change:

1. decreases the size of the libcore cache (to 16 hostnames).
2. brings the positive and negative TTLs way down (to 2s).
3. removes the dead code for the broken TTL-setting system properties.

Bug: 5841178
Bug: http://code.google.com/p/android/issues/detail?id=23878
Change-Id: Ib989c72bf3046300b4d59fa5ae49b8fe3ae6c2dc
10914811ea02b4acc7ab1dc5a0ada1b54cdf2203 29-Oct-2011 Elliott Hughes <enh@google.com> Improve the documentation of toString methods in the java.net package.

A developer wanted to know why their InterfaceAddress string began with a "/",
which wasn't obvious from our crappy documentation. This kind of thing should
always include examples, so let's include some examples...

Change-Id: Ic0a555c880e7f2dd31e4801926523f1aa96461c8
9b4a8ec37805be3eabf3a4b443bbdb692ffa2608 30-Sep-2011 Elliott Hughes <enh@google.com> Fix a couple of isReachable bugs.

We shouldn't throw NPE if you call isReachable on a deserialized InetAddress.
Fixed by removing the "globals", which also fixes the unreported bug that
calling isReachable on the same InetAddress was not thread-safe.

Bug: http://code.google.com/p/android/issues/detail?id=20203

Also, the arguments to isReachableByTCP in isReachable(NetworkInterface, int, int)
were the wrong way round, which meant we'd always return false (unless you were
asking if localhost was reachable).

Bug: http://code.google.com/p/android/issues/detail?id=20107

Bug: 2497441
Bug: 3213503

Change-Id: Ic808e774c28be6487e30e6acb8bc06f766f5c71d
92cb29d71ca8fadc9b738a33e63ca39807647463 30-Sep-2011 Elliott Hughes <enh@google.com> s/Ipv6/IPv6/

Change-Id: I59cacdbde1fe65b849d542f8faa8c0c2c0f5cddf
a7428d68453f6a74633221e8714f8d3d9597b2b4 29-Sep-2011 Elliott Hughes <enh@google.com> Fix the InetAddress/Inet4Address/Inet6Address documentation.

Also simplify a few of the implementations, and add a few tests.

Bug: http://code.google.com/p/android/issues/detail?id=19165
Change-Id: If33d5a830068114edf722711333bf0e00098d91a
fc041ff241f9a7556e72236f130de0215ecd17db 03-Jun-2011 Elliott Hughes <enh@google.com> Remove support for deprecated IPv4 address formats.

Bug: 4539262
Change-Id: Ic42173b7b06e8536e8c4331087720d7df1e1681a
9b510df35b57946d843ffc34cf23fdcfc84c5220 28-May-2011 Elliott Hughes <enh@google.com> Make ErrnoException a checked exception.

Bug: 4486011
Change-Id: I1877ce593d441653f75ab14884aa2d85f52652ad
0d4daefcf389b6433a0af481ef44a84a2546541a 21-May-2011 Elliott Hughes <enh@google.com> Suppress some FindBugs warnings.

Also globally replace "for(" with "for (".

Change-Id: I27fe17460e6745b9ca823f42e57c86fe8af31979
0b736ebc4efef64f2db1999aea90297ad8196146 20-May-2011 Elliott Hughes <enh@google.com> Move the stuff to bridge between io/net/nio semantics and POSIX semantics.

IoUtils should be more generally useful.

Change-Id: I5665f2a94d226ada3077a30045549a53cc741cf0
4728a015bcd3f432e000d1547c668e804015dc04 19-May-2011 Elliott Hughes <enh@google.com> More IPv6 sin6_scope_id fixes.

My earlier patch fixed the Java-to-native direction. This fixes the
native-to-Java direction, which didn't occur to us at the time.

I've also fixed the documentation so that public methods don't
define themselves in terms of a private method (that ought to
exist in the public API, but doesn't).

Change-Id: Ib16a5952bb69b0b96a66775304947f2a120a1dcf
23ec09188303a874b3b391f96ae0a29af002bff9 19-May-2011 Elliott Hughes <enh@google.com> Implement recvfrom(2).

This one's a little bit hairy because of multiple return values.

Bug: 3107501
Change-Id: I3bd35647d94bb6bc2192d6f31a39ecca07a3926e
ad5d31103472d57f5744ff5a03c3bc38dcb34740 17-May-2011 Elliott Hughes <enh@google.com> Fix InetAddress.isReachable.

Change-Id: I4b90b711642515a3abda54d176337738bdda1312
e27d02044ec399884bfd4343d513bf270b9b9b11 16-May-2011 Elliott Hughes <enh@google.com> Remove OSNetworkSystem.close.

For now I'm keeping AsynchronousCloseMonitor as a special case in native code.
We can see about doing something more general-purpose in a later pass.

Bug: 3107501
Change-Id: Ib79b9fc0bebfafc2d14896d957bd8591ae8e6e97
32b0fa4d1a31ef07bc4297c615f0fe50e9aa7c21 11-May-2011 Elliott Hughes <enh@google.com> DatagramSocket.disconnect is really a connect(2) of an AF_UNSPEC sockaddr.

Bug: 3107501
Change-Id: Ib04369b9ca63ff3fe7eb87dcbf2926fe704813e3
da15009528cc8300a6251f1d0931ac8657c9fc31 09-May-2011 Elliott Hughes <enh@google.com> Expose bind(2).

I've renamed the java.net.InetAddress to struct sockaddr conversion functions
too, after initially screwing up this patch by copy & pasting a usage of the
one that only one caller actually wants. Now the name's so ugly no-one will
be likely to use it by accident.

Bug: 3107501
Change-Id: I869a8d27fc40e462505e02bf25a67e771a403e92
1c039d71d3879f39e3a75b8788e656f7b4f88f08 05-May-2011 Elliott Hughes <enh@google.com> Add getaddrinfo(2).

This only supports the "node" side of getaddrinfo(2), not the "service" side.
There's also no support for AI_CANONNAME, so we currently return InetAddress[]
rather than anything equivalent to C's linked list of struct addrinfo.

Bug: 3107501
Change-Id: I8cf6baa3027a0fa05ac6e2f8fcc1dd8b576ff8c4
220c0af1763283b75617226efe3919c3e3b044c8 30-Apr-2011 Elliott Hughes <enh@google.com> Rewrite blocking connects in terms of the non-blocking primitives.

This simplifies OSNetworkSystem, getting us closer to replacing the
connect(2)-related bits with our new POSIX interface. It also lets
us remove cruft on the Java side that was resetting the socket's
blocking/non-blocking state (which should never have been touched),
which in turn fixes bug 4193212.

Detail messages for socket timeouts get better too, now we're throwing
on the Java side.

The only thing that's worse is that we used to get away with throwing
a checked exception from native code, which simplified our "throws"
clauses. Now we actually have to jump through a few hoops to make javac
happy. (Especially awkward because SocketTimeoutException isn't a
SocketException.) Stupid checked exceptions.

Bug: 4193212
Bug: 3107501
Change-Id: I00695d22094e6d785458dfbb7050fbaecf2db89f
6ab70f360e76509de958d6e7ea26b6ca3150c071 22-Apr-2011 Elliott Hughes <enh@google.com> Remove a work-around for a problem we don't think can occur.

We should always have a fully-qualified name at this point, so this
shouldn't be possible.

Change-Id: Icc7d6c16f51080c36ef4687744d7a42206a140a0
ae394a866dd86df8819b652dfe00b3d2c7ee204c 20-Apr-2011 Elliott Hughes <enh@google.com> Remove "java.net.preferIPv6Addresses", which has been true since Eclair.

Also ensure all javadoc references to RFCs are links.

Change-Id: I58b08a8ead08d6eab018e19ec2cff7d60f2b06e6
775095bf6a763e6a9b4e858011a812425d949af5 20-Apr-2011 Elliott Hughes <enh@google.com> Remove an unnecessary special case in InetAddress.getAllByName.

(And add a test to ensure it remains unnecessary.)

Change-Id: Ia1b4f0721308a36d972da36c06869ce4740b1cda
4f11ebea266eada830d507b8f011e811a8e5d7bc 20-Apr-2011 Elliott Hughes <enh@google.com> Add getnameinfo(3) (and gai_strerror(3)).

There's quite a large corresponding change to InetAddress, plus I've changed
the documentation for all the Permission classes to match the handful that
we'd already documented as legacy cruft.

Bug: http://b/3107501
Change-Id: Ia67aba79f0ab13e64085bd4a2df20ad0776bcc5b
454a95f6a28855aa3c88d168b15a45bf315efc99 30-Mar-2011 Elliott Hughes <enh@google.com> Add socket(2) and start adding setsockopt(2).

I've added just enough setsockopt to keep the hack from our old socket
creation code. More later (but not necessarily right away).

Bug: 3107501
Change-Id: Id57bdd3c760bc58ed79d675b268c55493cbc24c8
7341b9ed7157a1e37a3e69a0974676da358b735a 24-Mar-2011 Elliott Hughes <enh@google.com> Add uname(2).

This replaces InetAddress's use of gethostname(2), and System's hard-coded use
of uname(2) itself.

Bug: 3107501
Change-Id: I7e808177eece1e38428fea18a96c65628d51d93e
f934c3d2c8dd9e6bc5299cef41adace2a671637d 15-Mar-2011 Elliott Hughes <enh@google.com> Make OSMemory the semi-supported libcore.io.Memory.

Looks like we're not going to bother with a separate libcore.os package,
when libcore.io will do.

Change-Id: I2806c59349ed4b6410d768c4207c384ced973c54
4f9ffffd8a2835c30647f9785afb48fa96a0f045 05-Mar-2011 Elliott Hughes <enh@google.com> Add new InetSocketAddress.getHostString method.

Bug: 3484927
Change-Id: I265ed467b733b9d5842e2e0bf14af1eddc8e0de2
5d3f5562c167120b5ec00e509af0f0ab9308bff5 04-Mar-2011 Elliott Hughes <enh@google.com> Add InetAddress.getLoopbackAddress.

Bug: 3484927
Change-Id: Ic5305c852ed8079d958d8ab7c46fe10cceac60d4
46bed6a47a20d8105f0e099d162d547a7964b4fe 24-Feb-2011 Elliott Hughes <enh@google.com> Make InetAddress.parseNumericAddress more like InetAddress.getByName.

Specifically, treat null and "" as requests for the loopback address.

Bug: 3483011
Change-Id: I656f1d2873faf4b73e1fc7621c96183a8a86992b
f39b892d87e85835f021e8ad77ffdd215735604b 16-Feb-2011 Elliott Hughes <enh@google.com> Add InetAddress.parseNumericAddress for frameworks/base's benefit.

Bug: 3300307
Change-Id: Ifb2207621232314046aee39fdb86b957b9e7f8fc
e26ba79900d471d02d656f686926918ef7dc751f 08-Feb-2011 Elliott Hughes <enh@google.com> Use int.class instead of Integer.TYPE (et cetera) for clarity.

I've also removed some small amount of duplication and a few unused imports.

Change-Id: Ie52477484bade74c80a348ad1261b596f9053cf6
28eb98ecd43c27702e85b0561e040e2da10320a6 05-Feb-2011 Elliott Hughes <enh@google.com> Fix serialization of DecimalFormatSymbols.

Missing 'final' on the serialPersistentFields declaration meant we were
falling back to reflection, and 'exponential' isn't actually a field.

I've checked all the other serialPersistentFields fields, and put them
in a canonical form. There were no other errors.

I'll do two other related changes: I'll replace confusing use of Character.TYPE
with char.class (and so forth), and I'll backport the active ingredient from
this change so it's fixed in honeycomb-mr1.

Bug: http://code.google.com/p/android/issues/detail?id=14495
Change-Id: I954da649ad597450bee54957dc0e3d3aa9d151dd
a9c6c9013b08934867f71b69a90efce0c1b66918 11-Jan-2011 Elliott Hughes <enh@google.com> Documentation improvements for socket options.

Bug: http://code.google.com/p/android/issues/detail?id=13898
Change-Id: I202a5404e7e828f074483a3f6365b4e3a941da7d
87548e8585334658c3ee89050ec917a10ca35e5a 07-Jan-2011 Elliott Hughes <enh@google.com> More SecurityManager cleanup.

Bug: 2585285
Change-Id: Ib9c5fdadc1361d67227b6f82a774b76c53840ff0
ad41624e761bcf1af9c8008eb45187fc13983717 07-Jan-2011 Elliott Hughes <enh@google.com> Retire SecurityManager.

This change removes all the code that was calling getSecurityManager, and
removes all use of AccessController.doPrivileged. It also changes the
implementation of AccessController so it doesn't actually do anything; it's
only there for source-level compatibility.

Bug: 2585285
Change-Id: I1f0295a4f12bce0316d8073011d8593fee116f71
b46dab348e2007bc08abaf7ecae34d89a2474e50 09-Dec-2010 Elliott Hughes <enh@google.com> Rewrite all backwards comparisons.

Strictly, all the ones I could find. This is everything with 0 or null on the
left-hand side.

Note that this touches several incorrect bounds checks, which I haven't fixed:
I'm going to come back and finish that independent cleanup separately.

Change-Id: Ibdb054b53df9aace47c7d2a00ff19122190053e8
1f0c4ff5de23e466032f1810172f16ad0077fa65 07-Dec-2010 Jesse Wilson <jessewilson@google.com> Fix InetAddress tests that fail on the host.

Most of the fixes are to the tests. The InetAddress.getByAddress()
method has been changed to keep the user-reported host name.

Change-Id: I204caa5b975693144096e4ae1960682018c254d8
http://b/3238788
0d93c38cc3c7a5001aece8a18cafc6d1fc7551f3 04-Nov-2010 Elliott Hughes <enh@google.com> Add a public @hide InetAddress.isNumeric.

Some frameworks/base callers want to know whether they can call
getAllByName/getByName without incurring a DNS lookup. Rather than have them
write their own JNI to do the AI_NUMERICHOST getaddrinfo(3) call, let's just
offer them ours.

Why don't I fully expose getaddrinfo(3)? Because it doesn't map to Java API
very well, and no-one needs that yet. So for now, let's take the easy way out.

Also improve some misleading javadoc.

Bug: 3073384
Change-Id: Ia1990313306254598a4e1480cae356f68ceaaf22
0eb70e31581a977afa5df3292d1c96e42e548821 28-Oct-2010 Elliott Hughes <enh@google.com> Optimize DataInputStream and a few friends.

Also ensure that we're doing a correct readFully when reading
shorts/ints/longs.

Bug: 3032515
Change-Id: I39e6f926537f5d55063db8fc1c5a1b4b794746d4
fbbae9740d65620b417b85576aa0d6c7daf4ba34 28-Oct-2010 Elliott Hughes <enh@google.com> Improve UnknownHostException detail messages.

Bug: 2542766
Change-Id: I7de3c8326508294fb5d9f17f65b3f36c8fa856fa
b744a7edf23c14216698ad69ea59151e07cc50b8 13-Oct-2010 Elliott Hughes <enh@google.com> Add a hidden method to clear our Java-level DNS cache.

So the network guys can call this when the network changes, in case addresses
that were valid on that network aren't valid on the new network.

Change-Id: I07175b9b754bb4745a2f78b43f024723891c3f05
171dc20afe5071d5cbfad7103903bfa2c1f8d00f 02-Sep-2010 Elliott Hughes <enh@google.com> Use idiomatic Java "type[] id" syntax instead of "type id[]".

I've left xalan and the other xml filth alone, as usual.

Change-Id: I6be274501fff73e67ca6b3c872704988e0e30486
95c82c8a020e48793dd5db33ba1a20f9ef01737a 02-Sep-2010 Elliott Hughes <enh@google.com> Fix "java.net.preferIPv6Addresses".

I wrote getBoolean (a bogus method that shouldn't even exist) when I meant
parseBoolean.

Change-Id: Ib8c1cefdf0242fdc2b613850ec88ca35a1a83dea
3db0d1b07a79c3c871b0aa0929674adae3081b4f 28-Aug-2010 Elliott Hughes <enh@google.com> Remove the accessors hiding our IFileSystem and INetworkSystem.

These accessors aren't buying us anything, are costing us something, and have
encouraged caching of instances in fields all over the place. Lose all that
cruft.

I think we all agree that we want to merge IFileSystem and INetworkSystem at
some point, but I'll do that some other day.

Change-Id: I07696ec9650d0395ec31a71a74300e818a3fed91
29183729e5671a819d5f735969c7772804457b9f 19-Aug-2010 Elliott Hughes <enh@google.com> Minor net cleanup.

Move two constants to where they belong, and fix a well-intentioned but broken
detail message (confusion between two locals: an InetSocketAddress and its
InetAddress --- when the latter is null, we want to print the former).

Change-Id: Ic6a29edb31c0cde11f03ec511a3a9a864fec957f
a92f883cda9e483c64f78dbba0031e6e43cd00ab 12-Aug-2010 Elliott Hughes <enh@google.com> Replace createDatagramSocket and createStreamSocket with one call.

(Continuing our policy of having native methods' names correspond to the
underlying syscall, this one sadly gets the ugly name of "socket".)

Change-Id: Icf08e4e0637ee3ae9eab673d350860181f547250
0917c4a9d5d0115950450cdd0bb46e43a48da5db 12-Aug-2010 Elliott Hughes <enh@google.com> Clean up some dead/useless code.

(The DatagramPacketTest.java change is unrelated, but it's been lurking in my
repository for weeks now.)

Change-Id: I65d3ad53dd30709b2daed3c5787cc38c6081ffea
7365de1056414750d0a7d1fdd26025fd247f0d04 12-Aug-2010 Jesse Wilson <jessewilson@google.com> Sorting imports.

Change-Id: I8347bc625480a1c37a1ed9976193ddfedeb00bbc
036ffc75d2b7ece42bcd97f290c026e215868ba9 05-Aug-2010 Elliott Hughes <enh@google.com> Rationalize and simplify our "connect" implementations.

We don't need to copy a context structure back and forth between native code
and Java: it didn't contain anything but temporaries anyway. We don't need a
convenience method for a blocking connect with no timeout. We don't need a
separate codepath for datagram and stream sockets' connect calls.

There are further simplifications that could be made, I think. I think we
could implement "connect" in Java in terms of "connectNonBlocking" and
"isConnected" (since that's how our native implementation works anyway).
I also think we can fix the 100ms polling too, though I haven't investigated
and that may require that we fix the general "interrupt on close" problem.

Change-Id: Ib5989fa05f5dd7dd24b681fab70f856cd0bc5c56
4fe378672d700aaae3a50db956b693b3ed599c7d 31-Jul-2010 Elliott Hughes <enh@google.com> Remove "java.net.preferIPv4Stack" (which has been broken >= eclair).

Change-Id: I4733a0e266ff7c02c25033e79bcceff4d7357868
2cd82d7111f68ff63145ef7c393bf1479ff06223 29-Jul-2010 Elliott Hughes <enh@google.com> Fix setTrafficClass.

Pass the traffic class setting down to the kernel, rather than trying to
fake it in Java and then not actually using it at all in the native code.

There are two ways to set traffic class (aka type of service, or TOS):
per-packet or per-socket. The Java API is for the per-socket style, but
the old implementation had each SocketImpl intercept calls to
SocketOptions.setOption for SocketOptions.IP_TOS, stash the traffic class
in one of the SocketImpl's private fields, skip calling native code, and
then pass the traffic class to each native method that would need it to
implement the per-packet style. Unfortunately, each of those methods was
just ignoring the traffic class.

I've removed all this interception, so we now pass the traffic class straight
to the kernel via setsockopt(2), and we don't need to pass anything to the
individual per-packet calls.

The motivation for going the per-packet route appears to have been to work
around a lack of support for the per-socket route in old versions of Linux
and other OSes. It all works now, though, so there's no point making our
lives harder (and doing more work at runtime) to work around bugs and
infelicities that no longer exist.

I tested the new code manually with tcpdump, for both IPv4 (radio) and
IPv6 (wifi), and in both cases it looks like it's doing the right thing now.
We also still pass all of our tests, though none of them are capable of
recognizing whether we're actually doing anything useful anyway...

Change-Id: Ice241e088d25037123c73733a3f2bfade976fb31
79ff4e73fd689dae6667a8137ee57137962ff13a 14-Jul-2010 Elliott Hughes <enh@google.com> Make it possible to interrupt network reads.

This patch simplifies the network I/O interface, in particular for read/recv.

The bounds checking from OSNetworkSystem.read goes, since the caller already
checks. (If we want that checking in native code, we should add it uniformly.)

We also remove supportsUrgentData (which was always returning true), and remove
the sole caller, so we just try the operation and report failures if they happen
rather than trying to predict the failure (as the original code seemed to want
to do, and which is never a good idea).

The native code gains logic to recognize when the FileDescriptor has been
closed from another thread, though this logic remains largely unused at this
point. (There's comment-out code in "close" that does a shutdown(2) to wake
us up so we can recognize this situation.) I've switched code over to using
the new NetFd class, but haven't ensured that we handle the wakeups correctly.
(The "read" implementation being the notable exception.) For now, with the
shutdown(2) commented out, this shouldn't have any visible behavioral changes.
(And our tests don't spot any.)

Code that was using malloc(3)/free(3) to allocate temporary buffers, and copying
to and from those buffers has been rewritten to use JNI-provided pointers onto
the heap, as part of the general "don't lie to the garbage collector" push.

The implementations for the various old forms of recv have been collapsed into
one.

Bug: 2823977
Change-Id: I05cf742c44827a24df3c1ff59727013ee4636233
ccbe3404e0691dab506d017550658e8e5974c83e 10-Jul-2010 Elliott Hughes <enh@google.com> Use 'dst' (or an even more appropriate name where possible) rather than 'dest'.

(The ArrayIndexOutOfBoundsException for System.arraycopy already talks
about 'dst' and 'dstPos'.)

Change-Id: Iba9415dd4a9ec3b457938ea4469b4a0024bab6e4
7983be972905950b4a4e7d66df908f083c81ee29 16-Jun-2010 Brad Fitzpatrick <bradfitz@android.com> Sprinkle BlockGuard checks on DNS lookups.

Change-Id: Ib1ac2ce633fc1277ab8b6f11da37a739d0995cfe
753dcd862b31e85766225590d90ba0b9f481176f 02-Jun-2010 Elliott Hughes <enh@google.com> Refactor some of the OSNetworkSystem stuff to more appropriate homes.

Also rewrite PlainDatagramSocketImpl.peek in terms of existing primitives
rather than requiring its own. I still don't see how it can get called, but
at least now it doesn't require its own native code.

Bug: 2686833

Change-Id: I0453add66dab4c7095ee2a3f51a49efbd1205598
4adff24306c86433ce4f771da8489a574e63318e 27-May-2010 Elliott Hughes <enh@google.com> Javadoc improvements.

Bug: 2718660
Change-Id: Ifae8541d269ac0fa5581802a8d78453af19a0e10
77160e9cd7841fcf49d20b97a75d60e827c351ee 21-May-2010 Jesse Wilson <jessewilson@google.com> Redo HttpCookie.parse().

The previous code failed on quoted strings like ;Port="80,8080".
It also had weird behavior, like not supporting Expires headers
when the requesting locale wasn't English.

Tested with Harmony's tests and our CookieTest.

Change-Id: I271817b6febd30248f55f834cdcc2e3d5dfcd4c2
f33eae7e84eb6d3b0f4e86b59605bb3de73009f3 13-May-2010 Elliott Hughes <enh@google.com> Remove all trailing whitespace from the dalvik team-maintained parts of libcore.

Gentlemen, you may now set your editors to "strip trailing whitespace"...

Change-Id: I85b2f6c80e5fbef1af6cab11789790b078c11b1b
38607710cdc82cb1a0e81c2fc5c78278b435e4fc 23-Apr-2010 Jesse Wilson <jessewilson@google.com> Remove unnecessary IPv6 and IPv4 parsing from URI.

Cleanup URI and InetAddress exception localization.
97144c87ada735a82221d7cdf65555b8f063a05a 30-Mar-2010 Elliott Hughes <enh@google.com> Trivial tidying up of networking code.

Removing cruft and renaming things.

Change-Id: I317726c40a1addf3a1ad9d905239438424082549
ce64852f32d7d10ebd61a9c8f9ba2e91068f9bd2 23-Mar-2010 Elliott Hughes <enh@google.com> Improve java.net.InetAddress.getLocalHost documentation.

Bug: 1518707
Change-Id: I741a7a28325320949e84e997e6a49d3356c9a308
d2af45a6fd008ceb958ac74e5a50e582b8419e9c 05-Mar-2010 Elliott Hughes <enh@google.com> Implement the Java 6 NetworkInterface/InterfaceAddress functionality.

The Java bits are based on harmony's code (though only the bit that pulls
out the sub-interfaces is copied verbatim), but the native side is new
code, continuing our previous plan of (a) doing the least possible work
on the native side and (b) using the BSD getifaddrs(3) interface as our
portability layer.

This patch also updates our NetworkInterfaceTest to be the latest code
from harmony's java6 branch.

We pass all the harmony and jtreg tests, and visual inspection shows that
the untested (and hard to test) bits -- such as prefix length and hardware
address -- are correct.
a2a7fa1da77a6aaac09595f5712bc4a450ad2025 12-Feb-2010 Steinar H. Gunderson <sesse@google.com> Keep the order from getaddrinfo() unchanged if preferIPv6Addresses() is true.
4c5cbf2953ada194c4dc9d7b387615b1c6fe3e63 20-Jan-2010 Elliott Hughes <enh@google.com> One true way to query "java.net.preferIPv6Addresses".

Also stop querying and passing this boolean to code that doesn't care. (We
sort our InetAddress[]s appropriately, so most code doesn't need to worry
about this.)

Bug: http://code.google.com/p/android/issues/detail?id=5903
048303b64df9c987ae2f57b6bf88ff5ac1b5cca0 16-Jan-2010 Elliott Hughes <enh@google.com> Rewrite InetAddress' DNS cache.

Replace harmony's two 5-element linked lists with a single 512-element
LinkedHashMap. Greatly reduce the time we spend under locks (and no network
I/O is done under a lock any more!). Take advantage of various properties
of how the cache is used to avoid having to do much explicit work to handle
expiry.

I've also optimized the usual no-SecurityManager/no custom system properties
configuring cache TTLs case (without making the slow path much slower than it
already was).

I've also updated the native method names to correspond to the C functions
they're really wrapping (rather than completely different IPv4-only ones
they probably used to wrap long ago).

I've also improved the InetAddress documentation.

Bug: 2320435
55392539fea537abfb6581b474918f9d611fba27 16-Dec-2009 Jesse Wilson <jessewilson@google.com> Update luni package to Harmony r888752.

Conflicts:
libcore/luni/META-INF/MANIFEST.MF
libcore/luni/make/findbugs-exclude-filter.xml
libcore/luni/src/main/java/java/io/BufferedOutputStream.java
libcore/luni/src/main/java/java/io/BufferedReader.java
libcore/luni/src/main/java/java/io/CharArrayReader.java
libcore/luni/src/main/java/java/io/StringReader.java
libcore/luni/src/main/java/java/lang/StrictMath.java
libcore/luni/src/main/java/java/lang/ref/ReferenceQueue.java
libcore/luni/src/main/java/java/net/Inet4Address.java
libcore/luni/src/main/java/java/net/InetAddress.java
libcore/luni/src/main/java/java/util/ArrayList.java
libcore/luni/src/main/java/java/util/EnumSet.java
libcore/luni/src/main/java/java/util/HugeEnumSet.java
libcore/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyConstantPool.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/DebugMemorySpy.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/Endianness.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/IFileSystem.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/IMemorySystem.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/INetworkSystem.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/IPlatformConstants.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/OSMemory.java
libcore/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java
libcore/luni/src/main/java/org/apache/harmony/luni/util/InputStreamExposer.java
libcore/luni/src/main/native/hyzip/shared/zipcache.c
libcore/luni/src/main/native/hyzip/shared/zipsup.c
libcore/luni/src/main/native/include/jni.h
libcore/luni/src/main/native/include/jni_types.h
libcore/luni/src/main/native/include/jvmti.h
libcore/luni/src/main/native/include/jvmti_types.h
libcore/luni/src/main/native/launcher/unix/main_hlp.c
libcore/luni/src/main/native/luni/shared/OSNetworkSystem.c
libcore/luni/src/main/native/luni/shared/file.c
libcore/luni/src/main/native/luni/windows/makefile
libcore/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java
libcore/luni/src/test/java/tests/api/java/io/BufferedOutputStreamTest.java
libcore/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java
libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest.java
libcore/luni/src/test/java/tests/api/java/net/SocketTest.java
libcore/luni/src/test/java/tests/api/java/util/ArrayListTest.java
libcore/luni/src/test/java/tests/api/java/util/EnumSetTest.java
libcore/luni/src/test/java/tests/api/java/util/TimerTest.java
4fefecee9d4a5d2a4510f516b4015607b19e8d09 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
fc354fea0c535ceef679e8856a73dd05be8351df 17-Oct-2009 Elliott Hughes <enh@google.com> Improve error handling in InetAddress native code.

Fix a bug where we changed the return values of functions such
as byteArrayToSocketAddress without changing the logic in the
callers that's supposed to distinguish success and failure.
For simplicity, I've switch all of these functions over to
returning bool, and I've gone through all the callers to ensure
we're using the right check now. (This is the majority of the
diff.)

Also switch to throwing IllegalArgumentException instead of SocketException
when we find ourselves with a bad byte[] --- before we were throwing
a checked exception we weren't allowed to (from native code, which
can't actually be checked statically) and then trying to cover up
in Java.

I've also simply removed one case where we were trying to mask an
OutOfMemoryError with a SocketException.

I also removed dead code in socketAddressToString: this function's
sole caller always passed false for withPort. This makes the
temporary variable and the copying (which was unsafe) unnecessary.

In instances where I was already changing the code, I've removed
bogus "handle == 0" failures, but I'll come back and remove all
the other instances in another patch.

Since I was in connectSocketImpl, I've removed the dead second half
of that method.
5839b909d9528b7726e678a4b696ed37df15d897 10-Oct-2009 Jesse Wilson <jessewilson@google.com> Udating luni to Harmony r823222.

Highlights:
- InputStream.skip concurrency issue
- "better" messages in bound exceptions for streams and arrays
- prefer fewer writes to underlying streams (using byte[] buffers)
- Rename subclasses to not reuse names from their superclasses
- PlatformAddressFactory.allocMap bugfix

Plus some spelling fixes, style fixes, serial version UIDs and other
boilerplate improvements.
e8596906d75fd8ccda31600d71ad56391cd7cd3a 19-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Manual merge of change I3665f82b into master.
7356e5631e05b8b31d22a7e303bdef8b1221b065 19-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Use native code to convert strings to IP addresses.

1. Add an ipStringToByteArray method to the OSNetworkSystem interface and
provide a native implementation for it.
2. Change InetAddress to use the new method.
3. Remove a mid-sized chunk of Inet6Util, which is now redundant.
4. Remove the KnownFailure annotations from the InetAddress, InetAddress and
Inet6Address tests that expected 1.2.3, 1.3 and 3 to be valid IPv4
addresses. These tests now pass again.
5. Removed an unused native method.
6. Added a comment to the top of the native socket implementation to the effect
that the file is significantly different from harmony.

Change-Id: I3665f82b00ebc089e9133cc6166dda5a99fa10e4
511ab05f7731dffa3480cbd0b79836b231f77ef6 19-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Manual merge of eclair change I26548922 into master.
ec67773c5d9bbdbff7e846ef28816a3870d4cac2 18-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Use native code to convert IP addresses to strings.

- Add a byteArrayToIpString method to the INetworkSystem interface and implement
it in native code
- Fix the native code so it does better error reporting
- Change InetAddress's getHostAddress, getHostName and getCanonicalHostName
methods to use it and remove the IPv4-only Java implementations
- Remove Inet6Util.createIPAddrStringFromByteArray
- Fix InetAddress so getByAddress(null) throws UnknownHostException instead of
NullPointerException for compatibility with the RI.

Change-Id: I26548922e9eed63b295173456183c4ab3ce20718
55b49708e6a5f5f5047513b67094257b32ff9e93 11-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Remove code duplication in InetAddress.getByAddress.

Change-Id: Id2d72572fbe5b26ff4be9a2c959c41a48b859ea0
051128862ae7c5c031b8ddb763848ed264a63746 26-Aug-2009 Lorenzo Colitti <lorenzo@google.com> InetAddress refactoring.

1. Refactor all protocol-specific methods from InetAddress into Inet[46]Address.
2. Move all protocol-specific constants from InetAddress into Inet[46]Address.

This change should have no effect on the stack's behaviour but makes it easy to
find parts of the code that still have dependencies on IPv4 so they can be
examined and fixed.

Change-Id: I70860ee04cf7c01bffaa35c8c64199f69d99826f
ca8f5b66c546d8545e41f71b6fb852424c681881 29-Jul-2009 Lorenzo Colitti <lorenzo@google.com> Store all IP addresses for a hostname instead of just one.
f5597e626ecf7949d249dea08c1a2964d890ec11 25-Jul-2009 Jesse Wilson <jessewilson@google.com> Integrate luni module (but not tests) to Harmony r772995.

Notable changes
- Stripped "@since Android 1.0" from many files. Most files
are now 100% the same in Dalvik and Harmony.
- AbstractStringBuilder.reverse() supports surrogates
- AbstractStringBuilder shares less to waste less memory
- Bitset optimized
- BufferedInputStream changed to support unsynchronized close()
- BufferedOutputStream does flushInternal
- BufferedReader supports EBCDIC NEL
- Collections.synchronizedList().indexOf() does a copy for more concurrency
- Classes in nio module changed: DatagramChannelImpl, SocketChannelImpl
and ServerSocketChannelImpl (these depend on internal APIs changed in
this update)
- DataInputStream/DataOutputStream now use a small buffer to limit the
number of times the underlying stream is accessed
- Date now has a minutes offset, more efficient toString()
- ExposedByteArrayInputStream: new internal class
- DeleteOnExit moved to top-level class
- FileDescriptor.isValid() now non-native
- Float, Double lessThan optimized (fix for compare(-0.0F, 0.0F) still pending)
- FileURLConnection now guesses content types from streams
- HashMap iterator changes
- Hashtable iterator changes
- INetworkSystem
- removes bind2(), createMulticastSocket, sendStream(),
- renames createSocket to createStreamSocket
- JarURLConnection rewritten
- LinkedHashMap: new iterator
- Locale, Currency, TimeZone: now use ICU in Harmony, plain Java in Dalvik
- ObjectInputStream: Accessor objects in Harmony, direct native in Dalvik
- ProxyClassFile - many changes
- String - optimized ascii for toLowerCase, toUpperCase, compare
- Timer - rewritten
- TreeMap - rewritten
- URLClassLoader - new
- URLConnection - new guessContentTypeFromStream(), uses org.apache.harmony.awt.www.content
to lookup content type handlers
adc854b798c1cfe3bfd4c27d68d5cee38ca617da 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
1c0fed63c71ddb230f3b304aac12caffbedf2f21 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
ac4f307115a738b0206030fe0d127f7c7f035b03 19-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132276
b7926325a1c1a370c84c81db80372f59af240a53 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
687f18b91f4a0a728a027579110953ee729adcb8 22-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127436
a0881d052ee72e3f7e773374e9b1aa75fbd6be4c 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
dd828f42a5c83b4270d4fbf6fce2da1878f1e84a 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
fdb2704414a9ed92394ada0d1395e4db86889465 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution