summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* Fix a bug, and protect against an unrelated class of bugs.Elliott Hughes2010-03-293-0/+12
| | | | | | | | | | | | If the Java array allocation in InetAddress.cpp failed, we'd free NULL instead of the previously-allocated structure. This is a new bug in froyo, but only happens in out of memory situations, so doesn't seem worth fixing there. Unrelatedly, let's disallow assignment and copying of all our RAII classes. This isn't a mistake I've seen made, but it's easy to protect against, so we may as well do so consistently. Change-Id: I2433b31ff983d388788b09e59e08d661f1725ecd
* Start cleaning up the Charset implementation.Elliott Hughes2010-03-261-0/+56
| | | | | | | | | | | | | | This was going to be https://issues.apache.org/jira/browse/HARMONY-6461, but I couldn't resist cleaning up some of the surrounding code, and ended up cleaning up some of our native code too. In the course of the afternoon I spent on this, I lost my conviction that the upstream change makes sense, so I reverted that, leaving this change just pure cleanup. (Note that the cleanup work is incomplete. This is an improvement, but there's plenty left to do. I just don't want to get too distracted until all the Java 6 changes are done.) Change-Id: I56841db5f6c038bbf7942e83a148dca546519269
* Add a general-purpose scoped pointer for libcore JNI.Elliott Hughes2010-02-101-0/+231
| | | | | | | This is a functional equivalent of C++0x's std::unique_ptr. (I'm not planning to use this in froyo, but I want it there in case I have to backport changes from dalvik-dev.)
* Improve the FileNotFoundExceptions thrown by OSFileSystem.open.Elliott Hughes2009-12-081-0/+53
| | | | | | | | | | | | | | When I improved the internals of java.io.File, I failed to keep OSFileSystem.open (which uses the internals of java.io.File) in sync, leading to misleading error reporting. java.io.File's internals now include a trailing NUL, which is useful for the native code but confuses Java if it tries to decode the byte[] as a UTF-8 sequence. This patch fixes the bug and also improves OSFileSystem.open's error reporting to include the reason for the failure. Bug: 2313271
* Rewrite NetworkInterface's JNI for IPv6.Elliott Hughes2009-11-202-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | The old ioctl SIOCGIFCONF implementation of getNetworkInterfaces only returns IPv4 addresses. Now we've switched everything over to IPv6, that's not good enough. This change (a) implements glibc/BSD-like getifaddrs(3)/freeifaddrs(3) for Android, and (b) rewrites our getNetworkInterfaces to use that method. Of particular note is that we now do more of the work in Java. The JNI hands back a Java equivalent of getifaddrs(3)'s linked list of ifaddrs structs. The new package-private java.net.InterfaceAddress class serves as Java's "struct ifaddrs". The old implementation was also broken: SIOCGIFCONF doesn't actually return interface indexes from the kernel as the old code believed, so we were pulling the address family out of the IPv4 address it returned, leading us to assign the index 2 to all network interfaces. This caused all kinds of weird behavior later. I also had to fix GenericIPMreq so that its interface index field is actually set. The native code gets passed one of these objects when setNetworkInterface is called, so it's kind of important that the object identify which interface it's supposed to correspond to. I've also added missing copyright headers. This fixes all of the harmony tests on the simulator and on the device. It fixes several but not all of the jtreg MulticastSocket and IPv6 tests.
* Don't allocate arbitrary-length buffers on the stack.Elliott Hughes2009-11-131-0/+55
A new LocalArray C++ class lets us specify a "reasonable" amount of stack to use, but transparently fall back to using the heap if we need more space. The three places I've chosen to use LocalArray in this patch are fairly random; all they have in common is that they're the places where we call GetStringUTFRegion. There are more places LocalArray will be useful: the java.io.File JNI in particular. Bug: 2257819