diff options
71 files changed, 660 insertions, 279 deletions
diff --git a/dalvik/src/main/java/dalvik/system/DexFile.java b/dalvik/src/main/java/dalvik/system/DexFile.java index d0bfe5f..f1a8013 100644 --- a/dalvik/src/main/java/dalvik/system/DexFile.java +++ b/dalvik/src/main/java/dalvik/system/DexFile.java @@ -16,15 +16,15 @@ package dalvik.system; +import android.system.ErrnoException; +import android.system.StructStat; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; -import libcore.io.ErrnoException; import libcore.io.Libcore; -import libcore.io.StructStat; /** * Manipulates DEX files. The class is similar in principle to diff --git a/dalvik/src/main/java/dalvik/system/DexPathList.java b/dalvik/src/main/java/dalvik/system/DexPathList.java index f3bee10..e364e40 100644 --- a/dalvik/src/main/java/dalvik/system/DexPathList.java +++ b/dalvik/src/main/java/dalvik/system/DexPathList.java @@ -16,6 +16,8 @@ package dalvik.system; +import android.system.ErrnoException; +import android.system.StructStat; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; @@ -26,11 +28,9 @@ import java.util.Collections; import java.util.Enumeration; import java.util.List; import java.util.zip.ZipFile; -import libcore.io.ErrnoException; import libcore.io.IoUtils; import libcore.io.Libcore; -import libcore.io.StructStat; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * A pair of lists of entries, associated with a {@code ClassLoader}. diff --git a/luni/src/main/java/android/system/ErrnoException.java b/luni/src/main/java/android/system/ErrnoException.java new file mode 100644 index 0000000..5114bec --- /dev/null +++ b/luni/src/main/java/android/system/ErrnoException.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * @hide + */ +public final class ErrnoException extends libcore.io.ErrnoException { + public ErrnoException(String functionName, int errno) { + super(functionName, errno); + } + + public ErrnoException(String functionName, int errno, Throwable cause) { + super(functionName, errno, cause); + } +} diff --git a/luni/src/main/java/android/system/GaiException.java b/luni/src/main/java/android/system/GaiException.java new file mode 100644 index 0000000..803fc29 --- /dev/null +++ b/luni/src/main/java/android/system/GaiException.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +import java.net.UnknownHostException; +import libcore.io.Libcore; + +/** + * An unchecked exception thrown when {@code getaddrinfo} or {@code getnameinfo} fails. + * This exception contains the native {@link #error} value, should sophisticated + * callers need to adjust their behavior based on the exact failure. + * + * @hide + */ +public final class GaiException extends RuntimeException { + private final String functionName; + + /** + * The native error value, for comparison with the {@code GAI_} constants in {@link OsConstants}. + */ + public final int error; + + public GaiException(String functionName, int error) { + this.functionName = functionName; + this.error = error; + } + + public GaiException(String functionName, int error, Throwable cause) { + super(cause); + this.functionName = functionName; + this.error = error; + } + + /** + * Converts the stashed function name and error value to a human-readable string. + * We do this here rather than in the constructor so that callers only pay for + * this if they need it. + */ + @Override public String getMessage() { + String gaiName = OsConstants.gaiName(error); + if (gaiName == null) { + gaiName = "GAI_ error " + error; + } + String description = Libcore.os.gai_strerror(error); + return functionName + " failed: " + gaiName + " (" + description + ")"; + } + + public UnknownHostException rethrowAsUnknownHostException(String detailMessage) throws UnknownHostException { + UnknownHostException newException = new UnknownHostException(detailMessage); + newException.initCause(this); + throw newException; + } + + public UnknownHostException rethrowAsUnknownHostException() throws UnknownHostException { + throw rethrowAsUnknownHostException(getMessage()); + } +} diff --git a/luni/src/main/java/android/system/Os.java b/luni/src/main/java/android/system/Os.java new file mode 100644 index 0000000..0ca22a9 --- /dev/null +++ b/luni/src/main/java/android/system/Os.java @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +import android.system.ErrnoException; +import android.system.GaiException; +import android.system.StructAddrinfo; +import android.system.StructFlock; +import android.system.StructGroupReq; +import android.system.StructGroupSourceReq; +import android.system.StructLinger; +import android.system.StructPasswd; +import android.system.StructPollfd; +import android.system.StructStat; +import android.system.StructStatVfs; +import android.system.StructTimeval; +import android.system.StructUcred; +import android.system.StructUtsname; +import android.util.MutableInt; +import android.util.MutableLong; +import java.io.FileDescriptor; +import java.io.InterruptedIOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.net.SocketException; +import java.nio.ByteBuffer; +import libcore.io.Libcore; + +/** + * @hide + */ +public final class Os { + private Os() {} + + public static FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException { return Libcore.os.accept(fd, peerAddress); } + public static boolean access(String path, int mode) throws ErrnoException { return Libcore.os.access(path, mode); } + public static void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.bind(fd, address, port); } + public static void chmod(String path, int mode) throws ErrnoException { Libcore.os.chmod(path, mode); } + public static void chown(String path, int uid, int gid) throws ErrnoException { Libcore.os.chown(path, uid, gid); } + public static void close(FileDescriptor fd) throws ErrnoException { Libcore.os.close(fd); } + public static void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.connect(fd, address, port); } + public static FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException { return Libcore.os.dup(oldFd); } + public static FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException { return Libcore.os.dup2(oldFd, newFd); } + public static String[] environ() { return Libcore.os.environ(); } + public static void execv(String filename, String[] argv) throws ErrnoException { Libcore.os.execv(filename, argv); } + public static void execve(String filename, String[] argv, String[] envp) throws ErrnoException { Libcore.os.execve(filename, argv, envp); } + public static void fchmod(FileDescriptor fd, int mode) throws ErrnoException { Libcore.os.fchmod(fd, mode); } + public static void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException { Libcore.os.fchown(fd, uid, gid); } + public static int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return Libcore.os.fcntlVoid(fd, cmd); } + public static int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return Libcore.os.fcntlLong(fd, cmd, arg); } + public static int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException { return Libcore.os.fcntlFlock(fd, cmd, arg); } + public static void fdatasync(FileDescriptor fd) throws ErrnoException { Libcore.os.fdatasync(fd); } + public static StructStat fstat(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstat(fd); } + public static StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstatvfs(fd); } + public static void fsync(FileDescriptor fd) throws ErrnoException { Libcore.os.fsync(fd); } + public static void ftruncate(FileDescriptor fd, long length) throws ErrnoException { Libcore.os.ftruncate(fd, length); } + public static String gai_strerror(int error) { return Libcore.os.gai_strerror(error); } + public static InetAddress[] getaddrinfo(String node, StructAddrinfo hints) throws GaiException { return Libcore.os.getaddrinfo(node, hints); } + public static int getegid() { return Libcore.os.getegid(); } + public static int geteuid() { return Libcore.os.geteuid(); } + public static int getgid() { return Libcore.os.getgid(); } + public static String getenv(String name) { return Libcore.os.getenv(name); } + public static String getnameinfo(InetAddress address, int flags) throws GaiException { return Libcore.os.getnameinfo(address, flags); } + public static SocketAddress getpeername(FileDescriptor fd) throws ErrnoException { return Libcore.os.getpeername(fd); } + public static int getpid() { return Libcore.os.getpid(); } + public static int getppid() { return Libcore.os.getppid(); } + public static StructPasswd getpwnam(String name) throws ErrnoException { return Libcore.os.getpwnam(name); } + public static StructPasswd getpwuid(int uid) throws ErrnoException { return Libcore.os.getpwuid(uid); } + public static SocketAddress getsockname(FileDescriptor fd) throws ErrnoException { return Libcore.os.getsockname(fd); } + public static int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptByte(fd, level, option); } + public static InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInAddr(fd, level, option); } + public static int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInt(fd, level, option); } + public static StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptLinger(fd, level, option); } + public static StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptTimeval(fd, level, option); } + public static StructUcred getsockoptUcred(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptUcred(fd, level, option); } + public static int gettid() { return Libcore.os.gettid(); } + public static int getuid() { return Libcore.os.getuid(); } + public static String if_indextoname(int index) { return Libcore.os.if_indextoname(index); } + public static InetAddress inet_pton(int family, String address) { return Libcore.os.inet_pton(family, address); } + public static InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException { return Libcore.os.ioctlInetAddress(fd, cmd, interfaceName); } + public static int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException { return Libcore.os.ioctlInt(fd, cmd, arg); } + public static boolean isatty(FileDescriptor fd) { return Libcore.os.isatty(fd); } + public static void kill(int pid, int signal) throws ErrnoException { Libcore.os.kill(pid, signal); } + public static void lchown(String path, int uid, int gid) throws ErrnoException { Libcore.os.lchown(path, uid, gid); } + public static void listen(FileDescriptor fd, int backlog) throws ErrnoException { Libcore.os.listen(fd, backlog); } + public static long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return Libcore.os.lseek(fd, offset, whence); } + public static StructStat lstat(String path) throws ErrnoException { return Libcore.os.lstat(path); } + public static void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { Libcore.os.mincore(address, byteCount, vector); } + public static void mkdir(String path, int mode) throws ErrnoException { Libcore.os.mkdir(path, mode); } + public static void mkfifo(String path, int mode) throws ErrnoException { Libcore.os.mkfifo(path, mode); } + public static void mlock(long address, long byteCount) throws ErrnoException { Libcore.os.mlock(address, byteCount); } + public static long mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset) throws ErrnoException { return Libcore.os.mmap(address, byteCount, prot, flags, fd, offset); } + public static void msync(long address, long byteCount, int flags) throws ErrnoException { Libcore.os.msync(address, byteCount, flags); } + public static void munlock(long address, long byteCount) throws ErrnoException { Libcore.os.munlock(address, byteCount); } + public static void munmap(long address, long byteCount) throws ErrnoException { Libcore.os.munmap(address, byteCount); } + public static FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return Libcore.os.open(path, flags, mode); } + public static FileDescriptor[] pipe() throws ErrnoException { return Libcore.os.pipe(); } + public static int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException { return Libcore.os.poll(fds, timeoutMs); } + public static void posix_fallocate(FileDescriptor fd, long offset, long length) throws ErrnoException { Libcore.os.posix_fallocate(fd, offset, length); } + public static int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pread(fd, buffer, offset); } + public static int pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pread(fd, bytes, byteOffset, byteCount, offset); } + public static int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pwrite(fd, buffer, offset); } + public static int pwrite(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pwrite(fd, bytes, byteOffset, byteCount, offset); } + public static int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, buffer); } + public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, bytes, byteOffset, byteCount); } + public static String readlink(String path) throws ErrnoException { return Libcore.os.readlink(path); } + public static int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.readv(fd, buffers, offsets, byteCounts); } + public static int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { return Libcore.os.recvfrom(fd, buffer, flags, srcAddress); } + public static int recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { return Libcore.os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress); } + public static void remove(String path) throws ErrnoException { Libcore.os.remove(path); } + public static void rename(String oldPath, String newPath) throws ErrnoException { Libcore.os.rename(oldPath, newPath); } + public static long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException { return Libcore.os.sendfile(outFd, inFd, inOffset, byteCount); } + public static int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { return Libcore.os.sendto(fd, buffer, flags, inetAddress, port); } + public static int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { return Libcore.os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port); } + public static void setegid(int egid) throws ErrnoException { Libcore.os.setegid(egid); } + public static void setenv(String name, String value, boolean overwrite) throws ErrnoException { Libcore.os.setenv(name, value, overwrite); } + public static void seteuid(int euid) throws ErrnoException { Libcore.os.seteuid(euid); } + public static void setgid(int gid) throws ErrnoException { Libcore.os.setgid(gid); } + public static int setsid() throws ErrnoException { return Libcore.os.setsid(); } + public static void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptByte(fd, level, option, value); } + public static void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException { Libcore.os.setsockoptIfreq(fd, level, option, value); } + public static void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptInt(fd, level, option, value); } + public static void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptIpMreqn(fd, level, option, value); } + public static void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException { Libcore.os.setsockoptGroupReq(fd, level, option, value); } + public static void setsockoptGroupSourceReq(FileDescriptor fd, int level, int option, StructGroupSourceReq value) throws ErrnoException { Libcore.os.setsockoptGroupSourceReq(fd, level, option, value); } + public static void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException { Libcore.os.setsockoptLinger(fd, level, option, value); } + public static void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException { Libcore.os.setsockoptTimeval(fd, level, option, value); } + public static void setuid(int uid) throws ErrnoException { Libcore.os.setuid(uid); } + public static void shutdown(FileDescriptor fd, int how) throws ErrnoException { Libcore.os.shutdown(fd, how); } + public static FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException { return Libcore.os.socket(domain, type, protocol); } + public static void socketpair(int domain, int type, int protocol, FileDescriptor fd1, FileDescriptor fd2) throws ErrnoException { Libcore.os.socketpair(domain, type, protocol, fd1, fd2); } + public static StructStat stat(String path) throws ErrnoException { return Libcore.os.stat(path); } + public static StructStatVfs statvfs(String path) throws ErrnoException { return Libcore.os.statvfs(path); } + public static String strerror(int errno) { return Libcore.os.strerror(errno); } + public static String strsignal(int signal) { return Libcore.os.strsignal(signal); } + public static void symlink(String oldPath, String newPath) throws ErrnoException { Libcore.os.symlink(oldPath, newPath); } + public static long sysconf(int name) { return Libcore.os.sysconf(name); } + public static void tcdrain(FileDescriptor fd) throws ErrnoException { Libcore.os.tcdrain(fd); } + public static void tcsendbreak(FileDescriptor fd, int duration) throws ErrnoException { Libcore.os.tcsendbreak(fd, duration); } + public static int umask(int mask) { return Libcore.os.umask(mask); } + public static StructUtsname uname() { return Libcore.os.uname(); } + public static void unsetenv(String name) throws ErrnoException { Libcore.os.unsetenv(name); } + public static int waitpid(int pid, MutableInt status, int options) throws ErrnoException { return Libcore.os.waitpid(pid, status, options); } + public static int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, buffer); } + public static int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, bytes, byteOffset, byteCount); } + public static int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.writev(fd, buffers, offsets, byteCounts); } +} diff --git a/luni/src/main/java/android/system/OsConstants.java b/luni/src/main/java/android/system/OsConstants.java new file mode 100644 index 0000000..f7e02af --- /dev/null +++ b/luni/src/main/java/android/system/OsConstants.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * @hide + */ +public final class OsConstants extends libcore.io.OsConstants { + private OsConstants() {} +} diff --git a/luni/src/main/java/libcore/io/StructAddrinfo.java b/luni/src/main/java/android/system/StructAddrinfo.java index 8c8181d..9862190 100644 --- a/luni/src/main/java/libcore/io/StructAddrinfo.java +++ b/luni/src/main/java/android/system/StructAddrinfo.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package libcore.io; +package android.system; import java.net.InetAddress; @@ -23,6 +23,8 @@ import java.net.InetAddress; * <a href="http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html"><netdb.h></a> * * TODO: we currently only _take_ a StructAddrinfo; getaddrinfo returns an InetAddress[]. + * + * @hide */ public final class StructAddrinfo { /** Flags describing the kind of lookup to be done. (Such as AI_ADDRCONFIG.) */ diff --git a/luni/src/main/java/libcore/io/StructFlock.java b/luni/src/main/java/android/system/StructFlock.java index 11c29df..4908420 100644 --- a/luni/src/main/java/libcore/io/StructFlock.java +++ b/luni/src/main/java/android/system/StructFlock.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package libcore.io; +package android.system; /** * Information returned/taken by fcntl(2) F_GETFL and F_SETFL. Corresponds to C's * {@code struct flock} from * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html"><fcntl.h></a> + * + * @hide */ public final class StructFlock { /** The operation type, one of F_RDLCK, F_WRLCK, or F_UNLCK. */ diff --git a/luni/src/main/java/libcore/io/StructGroupReq.java b/luni/src/main/java/android/system/StructGroupReq.java index 0bdf783..f7e7d0f 100644 --- a/luni/src/main/java/libcore/io/StructGroupReq.java +++ b/luni/src/main/java/android/system/StructGroupReq.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package libcore.io; +package android.system; import java.net.InetAddress; /** * Corresponds to C's {@code struct group_req}. + * + * @hide */ public final class StructGroupReq { public final int gr_interface; diff --git a/luni/src/main/java/libcore/io/StructGroupSourceReq.java b/luni/src/main/java/android/system/StructGroupSourceReq.java index 3ac94b8..f3958ad 100644 --- a/luni/src/main/java/libcore/io/StructGroupSourceReq.java +++ b/luni/src/main/java/android/system/StructGroupSourceReq.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package libcore.io; +package android.system; import java.net.InetAddress; /** * Corresponds to C's {@code struct group_source_req}. + * + * @hide */ public final class StructGroupSourceReq { diff --git a/luni/src/main/java/libcore/io/StructLinger.java b/luni/src/main/java/android/system/StructLinger.java index 9f149af..8c65336 100644 --- a/luni/src/main/java/libcore/io/StructLinger.java +++ b/luni/src/main/java/android/system/StructLinger.java @@ -14,11 +14,13 @@ * limitations under the License. */ -package libcore.io; +package android.system; /** * Corresponds to C's {@code struct linger} from * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html"><sys/socket.h></a> + * + * @hide */ public final class StructLinger { /** Whether or not linger is enabled. Non-zero is on. */ diff --git a/luni/src/main/java/libcore/io/StructPasswd.java b/luni/src/main/java/android/system/StructPasswd.java index 6f5e058..9a94d3d 100644 --- a/luni/src/main/java/libcore/io/StructPasswd.java +++ b/luni/src/main/java/android/system/StructPasswd.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package libcore.io; +package android.system; /** * Information returned by getpwnam(3) and getpwuid(3). Corresponds to C's * {@code struct passwd} from * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pwd.h.html"><pwd.h></a> + * + * @hide */ public final class StructPasswd { public String pw_name; diff --git a/luni/src/main/java/libcore/io/StructPollfd.java b/luni/src/main/java/android/system/StructPollfd.java index c659d6e..9e65989 100644 --- a/luni/src/main/java/libcore/io/StructPollfd.java +++ b/luni/src/main/java/android/system/StructPollfd.java @@ -14,13 +14,15 @@ * limitations under the License. */ -package libcore.io; +package android.system; import java.io.FileDescriptor; /** * Corresponds to C's {@code struct pollfd} from * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/poll.h.html"><poll.h></a> + * + * @hide */ public final class StructPollfd { /** The file descriptor to poll. */ diff --git a/luni/src/main/java/android/system/StructStat.java b/luni/src/main/java/android/system/StructStat.java new file mode 100644 index 0000000..17221fd --- /dev/null +++ b/luni/src/main/java/android/system/StructStat.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * File information returned by fstat(2), lstat(2), and stat(2). Corresponds to C's + * {@code struct stat} from + * <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html"><stat.h></a> + * + * @hide + */ +public final class StructStat extends libcore.io.StructStat { + public StructStat(long st_dev, long st_ino, int st_mode, long st_nlink, int st_uid, int st_gid, + long st_rdev, long st_size, long st_atime, long st_mtime, long st_ctime, + long st_blksize, long st_blocks) { + super(st_dev, st_ino, st_mode, st_nlink, st_uid, st_gid, + st_rdev, st_size, st_atime, st_mtime, st_ctime, + st_blksize, st_blocks); + } +} diff --git a/luni/src/main/java/android/system/StructStatVfs.java b/luni/src/main/java/android/system/StructStatVfs.java new file mode 100644 index 0000000..b0eedb7 --- /dev/null +++ b/luni/src/main/java/android/system/StructStatVfs.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * File information returned by fstatvfs(2) and statvfs(2). + * + * @hide + */ +public final class StructStatVfs extends libcore.io.StructStatVfs { + public StructStatVfs(long f_bsize, long f_frsize, long f_blocks, long f_bfree, long f_bavail, + long f_files, long f_ffree, long f_favail, + long f_fsid, long f_flag, long f_namemax) { + super(f_bsize, f_frsize, f_blocks, f_bfree, f_bavail, + f_files, f_ffree, f_favail, + f_fsid, f_flag, f_namemax); + } +} diff --git a/luni/src/main/java/libcore/io/StructTimeval.java b/luni/src/main/java/android/system/StructTimeval.java index 0ed3509..c31ab3a 100644 --- a/luni/src/main/java/libcore/io/StructTimeval.java +++ b/luni/src/main/java/android/system/StructTimeval.java @@ -14,35 +14,38 @@ * limitations under the License. */ -package libcore.io; +package android.system; /** * Corresponds to C's {@code struct timeval} from * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_time.h.html"><sys/time.h></a> + * + * @hide */ public final class StructTimeval { - /** Seconds. */ - public final long tv_sec; - - /** Microseconds. */ - public final long tv_usec; - - private StructTimeval(long tv_sec, long tv_usec) { - this.tv_sec = tv_sec; - this.tv_usec = tv_usec; - } - - public static StructTimeval fromMillis(long millis) { - long tv_sec = millis / 1000; - long tv_usec = (millis - (tv_sec * 1000)) * 1000; - return new StructTimeval(tv_sec, tv_usec); - } - - public long toMillis() { - return (tv_sec * 1000) + (tv_usec / 1000); - } - - @Override public String toString() { - return "StructTimeval[tv_sec=" + tv_sec + ",tv_usec=" + tv_usec + "]"; - } + /** Seconds. */ + public final long tv_sec; + + /** Microseconds. */ + public final long tv_usec; + + private StructTimeval(long tv_sec, long tv_usec) { + this.tv_sec = tv_sec; + this.tv_usec = tv_usec; + } + + + public static StructTimeval fromMillis(long millis) { + long tv_sec = millis / 1000; + long tv_usec = (millis - (tv_sec * 1000)) * 1000; + return new StructTimeval(tv_sec, tv_usec); + } + + public long toMillis() { + return (tv_sec * 1000) + (tv_usec / 1000); + } + + @Override public String toString() { + return "StructTimeval[tv_sec=" + tv_sec + ",tv_usec=" + tv_usec + "]"; + } } diff --git a/luni/src/main/java/libcore/io/StructUcred.java b/luni/src/main/java/android/system/StructUcred.java index c13212c..563a904 100644 --- a/luni/src/main/java/libcore/io/StructUcred.java +++ b/luni/src/main/java/android/system/StructUcred.java @@ -14,10 +14,12 @@ * limitations under the License. */ -package libcore.io; +package android.system; /** * Corresponds to C's {@code struct ucred}. + * + * @hide */ public final class StructUcred { /** The peer's process id. */ diff --git a/luni/src/main/java/libcore/io/StructUtsname.java b/luni/src/main/java/android/system/StructUtsname.java index d7d606b..21e08bb 100644 --- a/luni/src/main/java/libcore/io/StructUtsname.java +++ b/luni/src/main/java/android/system/StructUtsname.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package libcore.io; +package android.system; /** * Information returned by uname(2). Corresponds to C's * {@code struct utsname} from * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_utsname.h.html"><sys/utsname.h></a> + * + * @hide */ public final class StructUtsname { /** The OS name, such as "Linux". */ diff --git a/luni/src/main/java/libcore/util/MutableBoolean.java b/luni/src/main/java/android/util/MutableBoolean.java index 359a8f9..90bf68c 100644 --- a/luni/src/main/java/libcore/util/MutableBoolean.java +++ b/luni/src/main/java/android/util/MutableBoolean.java @@ -14,12 +14,15 @@ * limitations under the License. */ -package libcore.util; +package android.util; +/** + * @hide + */ public final class MutableBoolean { - public boolean value; + public boolean value; - public MutableBoolean(boolean value) { - this.value = value; - } + public MutableBoolean(boolean value) { + this.value = value; + } } diff --git a/luni/src/main/java/libcore/util/MutableByte.java b/luni/src/main/java/android/util/MutableByte.java index 13f780b..65738b9 100644 --- a/luni/src/main/java/libcore/util/MutableByte.java +++ b/luni/src/main/java/android/util/MutableByte.java @@ -14,12 +14,15 @@ * limitations under the License. */ -package libcore.util; +package android.util; +/** + * @hide + */ public final class MutableByte { - public byte value; + public byte value; - public MutableByte(byte value) { - this.value = value; - } + public MutableByte(byte value) { + this.value = value; + } } diff --git a/luni/src/main/java/libcore/util/MutableChar.java b/luni/src/main/java/android/util/MutableChar.java index 1cafc3c..b59bab3 100644 --- a/luni/src/main/java/libcore/util/MutableChar.java +++ b/luni/src/main/java/android/util/MutableChar.java @@ -14,12 +14,15 @@ * limitations under the License. */ -package libcore.util; +package android.util; +/** + * @hide + */ public final class MutableChar { - public char value; + public char value; - public MutableChar(char value) { - this.value = value; - } + public MutableChar(char value) { + this.value = value; + } } diff --git a/luni/src/main/java/libcore/util/MutableDouble.java b/luni/src/main/java/android/util/MutableDouble.java index 4473ae6..3e2cc3a 100644 --- a/luni/src/main/java/libcore/util/MutableDouble.java +++ b/luni/src/main/java/android/util/MutableDouble.java @@ -14,12 +14,15 @@ * limitations under the License. */ -package libcore.util; +package android.util; +/** + * @hide + */ public final class MutableDouble { - public double value; + public double value; - public MutableDouble(double value) { - this.value = value; - } + public MutableDouble(double value) { + this.value = value; + } } diff --git a/luni/src/main/java/libcore/util/MutableFloat.java b/luni/src/main/java/android/util/MutableFloat.java index f81fba5..6e30501 100644 --- a/luni/src/main/java/libcore/util/MutableFloat.java +++ b/luni/src/main/java/android/util/MutableFloat.java @@ -14,12 +14,15 @@ * limitations under the License. */ -package libcore.util; +package android.util; +/** + * @hide + */ public final class MutableFloat { - public float value; + public float value; - public MutableFloat(float value) { - this.value = value; - } + public MutableFloat(float value) { + this.value = value; + } } diff --git a/luni/src/main/java/libcore/util/MutableInt.java b/luni/src/main/java/android/util/MutableInt.java index c8feb3a..8220c44 100644 --- a/luni/src/main/java/libcore/util/MutableInt.java +++ b/luni/src/main/java/android/util/MutableInt.java @@ -14,12 +14,15 @@ * limitations under the License. */ -package libcore.util; +package android.util; +/** + * @hide + */ public final class MutableInt { - public int value; + public int value; - public MutableInt(int value) { - this.value = value; - } + public MutableInt(int value) { + this.value = value; + } } diff --git a/luni/src/main/java/libcore/util/MutableLong.java b/luni/src/main/java/android/util/MutableLong.java index ad9b78e..5df6a0d 100644 --- a/luni/src/main/java/libcore/util/MutableLong.java +++ b/luni/src/main/java/android/util/MutableLong.java @@ -14,12 +14,15 @@ * limitations under the License. */ -package libcore.util; +package android.util; +/** + * @hide + */ public final class MutableLong { - public long value; + public long value; - public MutableLong(long value) { - this.value = value; - } + public MutableLong(long value) { + this.value = value; + } } diff --git a/luni/src/main/java/libcore/util/MutableShort.java b/luni/src/main/java/android/util/MutableShort.java index 78b4c33..3880fef 100644 --- a/luni/src/main/java/libcore/util/MutableShort.java +++ b/luni/src/main/java/android/util/MutableShort.java @@ -14,12 +14,15 @@ * limitations under the License. */ -package libcore.util; +package android.util; +/** + * @hide + */ public final class MutableShort { - public short value; + public short value; - public MutableShort(short value) { - this.value = value; - } + public MutableShort(short value) { + this.value = value; + } } diff --git a/luni/src/main/java/java/io/File.java b/luni/src/main/java/java/io/File.java index 9b98ecb..d107c28 100644 --- a/luni/src/main/java/java/io/File.java +++ b/luni/src/main/java/java/io/File.java @@ -17,6 +17,9 @@ package java.io; +import android.system.ErrnoException; +import android.system.StructStat; +import android.system.StructStatVfs; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -24,12 +27,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; import libcore.io.DeleteOnExit; -import libcore.io.ErrnoException; import libcore.io.IoUtils; import libcore.io.Libcore; -import libcore.io.StructStat; -import libcore.io.StructStatVfs; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * An "abstract" representation of a file system entity identified by a diff --git a/luni/src/main/java/java/io/FileDescriptor.java b/luni/src/main/java/java/io/FileDescriptor.java index e4eb06c..cb38123 100644 --- a/luni/src/main/java/java/io/FileDescriptor.java +++ b/luni/src/main/java/java/io/FileDescriptor.java @@ -17,9 +17,9 @@ package java.io; -import libcore.io.ErrnoException; +import android.system.ErrnoException; import libcore.io.Libcore; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * Wraps a Unix file descriptor. It's possible to get the file descriptor used by some diff --git a/luni/src/main/java/java/io/FileInputStream.java b/luni/src/main/java/java/io/FileInputStream.java index 5debe64..7944ef1 100644 --- a/luni/src/main/java/java/io/FileInputStream.java +++ b/luni/src/main/java/java/io/FileInputStream.java @@ -19,13 +19,13 @@ package java.io; import dalvik.system.CloseGuard; -import java.nio.NioUtils; +import android.system.ErrnoException; import java.nio.channels.FileChannel; -import libcore.io.ErrnoException; +import java.nio.NioUtils; import libcore.io.IoBridge; import libcore.io.Libcore; import libcore.io.Streams; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * An input stream that reads bytes from a file. diff --git a/luni/src/main/java/java/io/FileOutputStream.java b/luni/src/main/java/java/io/FileOutputStream.java index e796e80..f91ee20 100644 --- a/luni/src/main/java/java/io/FileOutputStream.java +++ b/luni/src/main/java/java/io/FileOutputStream.java @@ -22,7 +22,7 @@ import java.nio.NioUtils; import java.nio.channels.FileChannel; import libcore.io.IoBridge; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * An output stream that writes bytes to a file. If the output file exists, it diff --git a/luni/src/main/java/java/io/RandomAccessFile.java b/luni/src/main/java/java/io/RandomAccessFile.java index eac7641..da99765 100644 --- a/luni/src/main/java/java/io/RandomAccessFile.java +++ b/luni/src/main/java/java/io/RandomAccessFile.java @@ -17,18 +17,18 @@ package java.io; +import android.system.ErrnoException; import dalvik.system.CloseGuard; import java.nio.ByteOrder; -import java.nio.NioUtils; import java.nio.channels.FileChannel; import java.nio.charset.ModifiedUtf8; +import java.nio.NioUtils; import java.util.Arrays; -import libcore.io.ErrnoException; import libcore.io.IoBridge; import libcore.io.Libcore; import libcore.io.Memory; import libcore.io.SizeOf; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * Allows reading from and writing to a file in a random-access manner. This is diff --git a/luni/src/main/java/java/lang/ProcessManager.java b/luni/src/main/java/java/lang/ProcessManager.java index 28314b7..ec87fda 100644 --- a/luni/src/main/java/java/lang/ProcessManager.java +++ b/luni/src/main/java/java/lang/ProcessManager.java @@ -16,23 +16,23 @@ package java.lang; +import android.system.ErrnoException; +import android.util.MutableInt; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.io.IOException; import java.io.OutputStream; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import libcore.io.ErrnoException; import libcore.io.IoUtils; import libcore.io.Libcore; -import libcore.util.MutableInt; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * Manages child processes. diff --git a/luni/src/main/java/java/lang/Runtime.java b/luni/src/main/java/java/lang/Runtime.java index 8538f8a..4b66c2d 100644 --- a/luni/src/main/java/java/lang/Runtime.java +++ b/luni/src/main/java/java/lang/Runtime.java @@ -48,7 +48,7 @@ import java.util.StringTokenizer; import libcore.io.IoUtils; import libcore.io.Libcore; import libcore.util.EmptyArray; -import static libcore.io.OsConstants._SC_NPROCESSORS_CONF; +import static android.system.OsConstants._SC_NPROCESSORS_CONF; /** * Allows Java applications to interface with the environment in which they are diff --git a/luni/src/main/java/java/lang/System.java b/luni/src/main/java/java/lang/System.java index 7cf3993..ea87929 100644 --- a/luni/src/main/java/java/lang/System.java +++ b/luni/src/main/java/java/lang/System.java @@ -32,6 +32,9 @@ package java.lang; +import android.system.ErrnoException; +import android.system.StructPasswd; +import android.system.StructUtsname; import dalvik.system.VMRuntime; import dalvik.system.VMStack; import java.io.BufferedInputStream; @@ -39,8 +42,8 @@ import java.io.Console; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.io.IOException; import java.io.PrintStream; import java.nio.channels.Channel; import java.nio.channels.spi.SelectorProvider; @@ -51,10 +54,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import libcore.icu.ICU; -import libcore.io.ErrnoException; import libcore.io.Libcore; -import libcore.io.StructPasswd; -import libcore.io.StructUtsname; /** * Provides access to system-related information and resources including diff --git a/luni/src/main/java/java/net/DatagramSocket.java b/luni/src/main/java/java/net/DatagramSocket.java index 26825d2..f9b72d8 100644 --- a/luni/src/main/java/java/net/DatagramSocket.java +++ b/luni/src/main/java/java/net/DatagramSocket.java @@ -17,14 +17,14 @@ package java.net; +import android.system.ErrnoException; import java.io.Closeable; import java.io.FileDescriptor; import java.io.IOException; import java.nio.channels.DatagramChannel; -import libcore.io.ErrnoException; import libcore.io.IoBridge; import libcore.io.Libcore; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * This class implements a UDP socket for sending and receiving {@code diff --git a/luni/src/main/java/java/net/Inet4Address.java b/luni/src/main/java/java/net/Inet4Address.java index 7c26639..f0b1b5b 100644 --- a/luni/src/main/java/java/net/Inet4Address.java +++ b/luni/src/main/java/java/net/Inet4Address.java @@ -20,7 +20,7 @@ package java.net; import java.io.ObjectStreamException; import java.nio.ByteOrder; import libcore.io.Memory; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * An IPv4 address. See {@link InetAddress}. diff --git a/luni/src/main/java/java/net/Inet6Address.java b/luni/src/main/java/java/net/Inet6Address.java index 37e9c18..8ab0f8d 100644 --- a/luni/src/main/java/java/net/Inet6Address.java +++ b/luni/src/main/java/java/net/Inet6Address.java @@ -23,7 +23,7 @@ import java.io.ObjectOutputStream; import java.io.ObjectStreamField; import java.util.Arrays; import java.util.Enumeration; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * An IPv6 address. See {@link InetAddress}. diff --git a/luni/src/main/java/java/net/InetAddress.java b/luni/src/main/java/java/net/InetAddress.java index 885b472..e31b4c3 100644 --- a/luni/src/main/java/java/net/InetAddress.java +++ b/luni/src/main/java/java/net/InetAddress.java @@ -17,6 +17,9 @@ package java.net; +import android.system.ErrnoException; +import android.system.GaiException; +import android.system.StructAddrinfo; import dalvik.system.BlockGuard; import java.io.FileDescriptor; import java.io.IOException; @@ -28,16 +31,13 @@ import java.io.Serializable; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Collections; -import java.util.List; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; -import libcore.io.ErrnoException; -import libcore.io.GaiException; +import java.util.concurrent.CountDownLatch; +import java.util.List; import libcore.io.IoBridge; import libcore.io.Libcore; import libcore.io.Memory; -import libcore.io.StructAddrinfo; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and diff --git a/luni/src/main/java/java/net/InetUnixAddress.java b/luni/src/main/java/java/net/InetUnixAddress.java index 44b9cba..51236e2 100644 --- a/luni/src/main/java/java/net/InetUnixAddress.java +++ b/luni/src/main/java/java/net/InetUnixAddress.java @@ -18,7 +18,7 @@ package java.net; import java.nio.charset.StandardCharsets; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * An AF_UNIX address. See {@link InetAddress}. diff --git a/luni/src/main/java/java/net/NetworkInterface.java b/luni/src/main/java/java/net/NetworkInterface.java index 3128b98..852c09b 100644 --- a/luni/src/main/java/java/net/NetworkInterface.java +++ b/luni/src/main/java/java/net/NetworkInterface.java @@ -17,6 +17,7 @@ package java.net; +import android.system.ErrnoException; import java.io.File; import java.io.FileDescriptor; import java.io.IOException; @@ -26,10 +27,9 @@ import java.util.Collections; import java.util.Enumeration; import java.util.LinkedList; import java.util.List; -import libcore.io.ErrnoException; import libcore.io.IoUtils; import libcore.io.Libcore; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * This class is used to represent a network interface of the local device. An diff --git a/luni/src/main/java/java/net/PlainDatagramSocketImpl.java b/luni/src/main/java/java/net/PlainDatagramSocketImpl.java index a9ade28..eb0c99d 100644 --- a/luni/src/main/java/java/net/PlainDatagramSocketImpl.java +++ b/luni/src/main/java/java/net/PlainDatagramSocketImpl.java @@ -17,15 +17,15 @@ package java.net; +import android.system.ErrnoException; +import android.system.StructGroupReq; import dalvik.system.CloseGuard; import java.io.FileDescriptor; import java.io.IOException; -import libcore.io.ErrnoException; import libcore.io.IoBridge; import libcore.io.Libcore; -import libcore.io.StructGroupReq; import libcore.util.EmptyArray; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * @hide used in java.nio. diff --git a/luni/src/main/java/java/net/PlainSocketImpl.java b/luni/src/main/java/java/net/PlainSocketImpl.java index e3988ed..4e5ba44 100644 --- a/luni/src/main/java/java/net/PlainSocketImpl.java +++ b/luni/src/main/java/java/net/PlainSocketImpl.java @@ -17,19 +17,19 @@ package java.net; +import android.system.ErrnoException; import dalvik.system.CloseGuard; import java.io.FileDescriptor; -import java.io.IOException; import java.io.InputStream; +import java.io.IOException; import java.io.OutputStream; import java.nio.ByteOrder; import java.util.Arrays; -import libcore.io.ErrnoException; import libcore.io.IoBridge; import libcore.io.Libcore; import libcore.io.Memory; import libcore.io.Streams; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * @hide used in java.nio. diff --git a/luni/src/main/java/java/nio/DatagramChannelImpl.java b/luni/src/main/java/java/nio/DatagramChannelImpl.java index a303903..343ef00 100644 --- a/luni/src/main/java/java/nio/DatagramChannelImpl.java +++ b/luni/src/main/java/java/nio/DatagramChannelImpl.java @@ -17,9 +17,10 @@ package java.nio; +import android.system.ErrnoException; import java.io.FileDescriptor; -import java.io.IOException; import java.io.InterruptedIOException; +import java.io.IOException; import java.net.ConnectException; import java.net.DatagramPacket; import java.net.DatagramSocket; @@ -40,13 +41,11 @@ import java.nio.channels.DatagramChannel; import java.nio.channels.IllegalBlockingModeException; import java.nio.channels.MembershipKey; import java.nio.channels.NotYetConnectedException; +import java.nio.channels.spi.SelectorProvider; import java.nio.channels.UnresolvedAddressException; import java.nio.channels.UnsupportedAddressTypeException; -import java.nio.channels.spi.SelectorProvider; import java.util.Arrays; import java.util.Set; - -import libcore.io.ErrnoException; import libcore.io.IoBridge; import libcore.io.IoUtils; import libcore.io.Libcore; diff --git a/luni/src/main/java/java/nio/FileChannelImpl.java b/luni/src/main/java/java/nio/FileChannelImpl.java index 9a47706..4ed7dba 100644 --- a/luni/src/main/java/java/nio/FileChannelImpl.java +++ b/luni/src/main/java/java/nio/FileChannelImpl.java @@ -17,6 +17,9 @@ package java.nio; +import android.system.ErrnoException; +import android.system.StructFlock; +import android.util.MutableLong; import java.io.Closeable; import java.io.FileDescriptor; import java.io.IOException; @@ -32,11 +35,8 @@ import java.util.Arrays; import java.util.Comparator; import java.util.SortedSet; import java.util.TreeSet; -import libcore.io.ErrnoException; import libcore.io.Libcore; -import libcore.io.StructFlock; -import libcore.util.MutableLong; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * Our concrete implementation of the abstract FileChannel class. diff --git a/luni/src/main/java/java/nio/IoVec.java b/luni/src/main/java/java/nio/IoVec.java index f14f4f2..e20709c 100644 --- a/luni/src/main/java/java/nio/IoVec.java +++ b/luni/src/main/java/java/nio/IoVec.java @@ -16,10 +16,10 @@ package java.nio; +import android.system.ErrnoException; import java.io.FileDescriptor; import java.io.IOException; import libcore.io.Libcore; -import libcore.io.ErrnoException; /** * Used to implement java.nio read(ByteBuffer[])/write(ByteBuffer[]) operations as POSIX readv(2) diff --git a/luni/src/main/java/java/nio/MappedByteBuffer.java b/luni/src/main/java/java/nio/MappedByteBuffer.java index 5782457..ce19c0c 100644 --- a/luni/src/main/java/java/nio/MappedByteBuffer.java +++ b/luni/src/main/java/java/nio/MappedByteBuffer.java @@ -16,11 +16,11 @@ package java.nio; +import android.system.ErrnoException; import java.nio.channels.FileChannel.MapMode; -import libcore.io.ErrnoException; import libcore.io.Libcore; -import static libcore.io.OsConstants.MS_SYNC; -import static libcore.io.OsConstants._SC_PAGE_SIZE; +import static android.system.OsConstants.MS_SYNC; +import static android.system.OsConstants._SC_PAGE_SIZE; /** * {@code MappedByteBuffer} is a special kind of direct byte buffer which maps a diff --git a/luni/src/main/java/java/nio/MemoryBlock.java b/luni/src/main/java/java/nio/MemoryBlock.java index 6052b8f..1ce8fea 100644 --- a/luni/src/main/java/java/nio/MemoryBlock.java +++ b/luni/src/main/java/java/nio/MemoryBlock.java @@ -17,18 +17,18 @@ package java.nio; +import android.system.ErrnoException; import dalvik.system.VMRuntime; import java.io.FileDescriptor; import java.io.IOException; import java.nio.channels.FileChannel.MapMode; -import libcore.io.ErrnoException; import libcore.io.Libcore; import libcore.io.Memory; -import static libcore.io.OsConstants.MAP_PRIVATE; -import static libcore.io.OsConstants.MAP_SHARED; -import static libcore.io.OsConstants.PROT_READ; -import static libcore.io.OsConstants.PROT_WRITE; +import static android.system.OsConstants.MAP_PRIVATE; +import static android.system.OsConstants.MAP_SHARED; +import static android.system.OsConstants.PROT_READ; +import static android.system.OsConstants.PROT_WRITE; class MemoryBlock { /** diff --git a/luni/src/main/java/java/nio/MulticastMembershipHandler.java b/luni/src/main/java/java/nio/MulticastMembershipHandler.java index 7564d4e..2fe8130 100644 --- a/luni/src/main/java/java/nio/MulticastMembershipHandler.java +++ b/luni/src/main/java/java/nio/MulticastMembershipHandler.java @@ -1,5 +1,7 @@ package java.nio; +import android.system.StructGroupReq; +import android.system.StructGroupSourceReq; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; @@ -8,10 +10,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; - import libcore.io.IoBridge; -import libcore.io.StructGroupReq; -import libcore.io.StructGroupSourceReq; /** * A helper class for {@link DatagramChannelImpl} that keeps track of multicast group diff --git a/luni/src/main/java/java/nio/PipeImpl.java b/luni/src/main/java/java/nio/PipeImpl.java index d4dde3b..ebc8a91 100644 --- a/luni/src/main/java/java/nio/PipeImpl.java +++ b/luni/src/main/java/java/nio/PipeImpl.java @@ -16,16 +16,16 @@ package java.nio; +import android.system.ErrnoException; import java.io.Closeable; import java.io.FileDescriptor; import java.io.IOException; import java.nio.channels.Pipe; import java.nio.channels.SocketChannel; import java.nio.channels.spi.SelectorProvider; -import libcore.io.ErrnoException; import libcore.io.IoUtils; import libcore.io.Libcore; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /* * Implements {@link java.nio.channels.Pipe}. diff --git a/luni/src/main/java/java/nio/SelectorImpl.java b/luni/src/main/java/java/nio/SelectorImpl.java index 3495523..efa8712 100644 --- a/luni/src/main/java/java/nio/SelectorImpl.java +++ b/luni/src/main/java/java/nio/SelectorImpl.java @@ -15,9 +15,11 @@ */ package java.nio; +import android.system.ErrnoException; +import android.system.StructPollfd; import java.io.FileDescriptor; -import java.io.IOException; import java.io.InterruptedIOException; +import java.io.IOException; import java.nio.channels.ClosedSelectorException; import java.nio.channels.IllegalSelectorException; import java.nio.channels.SelectionKey; @@ -32,20 +34,18 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.UnsafeArrayList; -import libcore.io.ErrnoException; import libcore.io.IoBridge; import libcore.io.IoUtils; import libcore.io.Libcore; -import libcore.io.StructPollfd; +import static android.system.OsConstants.EINTR; +import static android.system.OsConstants.POLLHUP; +import static android.system.OsConstants.POLLIN; +import static android.system.OsConstants.POLLOUT; import static java.nio.channels.SelectionKey.OP_ACCEPT; import static java.nio.channels.SelectionKey.OP_CONNECT; import static java.nio.channels.SelectionKey.OP_READ; import static java.nio.channels.SelectionKey.OP_WRITE; -import static libcore.io.OsConstants.EINTR; -import static libcore.io.OsConstants.POLLHUP; -import static libcore.io.OsConstants.POLLIN; -import static libcore.io.OsConstants.POLLOUT; /* * Default implementation of java.nio.channels.Selector diff --git a/luni/src/main/java/java/nio/ServerSocketChannelImpl.java b/luni/src/main/java/java/nio/ServerSocketChannelImpl.java index 7a9ba7a..1b84797 100644 --- a/luni/src/main/java/java/nio/ServerSocketChannelImpl.java +++ b/luni/src/main/java/java/nio/ServerSocketChannelImpl.java @@ -17,6 +17,7 @@ package java.nio; +import android.system.ErrnoException; import java.io.FileDescriptor; import java.io.IOException; import java.net.InetSocketAddress; @@ -32,14 +33,12 @@ import java.nio.channels.IllegalBlockingModeException; import java.nio.channels.NotYetBoundException; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; +import java.nio.channels.spi.SelectorProvider; import java.nio.channels.UnresolvedAddressException; import java.nio.channels.UnsupportedAddressTypeException; -import java.nio.channels.spi.SelectorProvider; import java.util.Set; - -import libcore.io.ErrnoException; import libcore.io.IoUtils; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * The default ServerSocketChannel. diff --git a/luni/src/main/java/java/nio/SocketChannelImpl.java b/luni/src/main/java/java/nio/SocketChannelImpl.java index e4e92f3..9064f29 100644 --- a/luni/src/main/java/java/nio/SocketChannelImpl.java +++ b/luni/src/main/java/java/nio/SocketChannelImpl.java @@ -17,11 +17,12 @@ package java.nio; +import android.system.ErrnoException; import java.io.FileDescriptor; import java.io.FilterInputStream; import java.io.FilterOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.io.IOException; import java.io.OutputStream; import java.net.ConnectException; import java.net.Inet4Address; @@ -42,17 +43,15 @@ import java.nio.channels.IllegalBlockingModeException; import java.nio.channels.NoConnectionPendingException; import java.nio.channels.NotYetConnectedException; import java.nio.channels.SocketChannel; +import java.nio.channels.spi.SelectorProvider; import java.nio.channels.UnresolvedAddressException; import java.nio.channels.UnsupportedAddressTypeException; -import java.nio.channels.spi.SelectorProvider; import java.util.Arrays; import java.util.Set; - -import libcore.io.ErrnoException; -import libcore.io.Libcore; import libcore.io.IoBridge; import libcore.io.IoUtils; -import static libcore.io.OsConstants.*; +import libcore.io.Libcore; +import static android.system.OsConstants.*; /* * The default implementation class of java.nio.channels.SocketChannel. diff --git a/luni/src/main/java/libcore/io/BlockGuardOs.java b/luni/src/main/java/libcore/io/BlockGuardOs.java index eaa7f0c..238c5bd 100644 --- a/luni/src/main/java/libcore/io/BlockGuardOs.java +++ b/luni/src/main/java/libcore/io/BlockGuardOs.java @@ -16,6 +16,12 @@ package libcore.io; +import android.system.ErrnoException; +import android.system.StructLinger; +import android.system.StructPollfd; +import android.system.StructStat; +import android.system.StructStatVfs; +import android.util.MutableLong; import dalvik.system.BlockGuard; import dalvik.system.SocketTagger; import java.io.FileDescriptor; @@ -24,8 +30,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketException; import java.nio.ByteBuffer; -import libcore.util.MutableLong; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * Informs BlockGuard of any activity it should be aware of. diff --git a/luni/src/main/java/libcore/io/ErrnoException.java b/luni/src/main/java/libcore/io/ErrnoException.java index f484ce9..2a8c1c2 100644 --- a/luni/src/main/java/libcore/io/ErrnoException.java +++ b/luni/src/main/java/libcore/io/ErrnoException.java @@ -20,11 +20,11 @@ import java.io.IOException; import java.net.SocketException; /** - * A checked exception thrown when {@link Os} methods fail. This exception contains the native + * An unchecked exception thrown when {@link Os} methods fail. This exception contains the native * errno value, for comparison against the constants in {@link OsConstants}, should sophisticated * callers need to adjust their behavior based on the exact failure. */ -public final class ErrnoException extends Exception { +public /* not final for android.system.ErrnoException */ class ErrnoException extends Exception { private final String functionName; public final int errno; diff --git a/luni/src/main/java/libcore/io/ForwardingOs.java b/luni/src/main/java/libcore/io/ForwardingOs.java index 0b49071..3e63cf6 100644 --- a/luni/src/main/java/libcore/io/ForwardingOs.java +++ b/luni/src/main/java/libcore/io/ForwardingOs.java @@ -16,6 +16,22 @@ package libcore.io; +import android.system.ErrnoException; +import android.system.GaiException; +import android.system.StructAddrinfo; +import android.system.StructFlock; +import android.system.StructGroupReq; +import android.system.StructGroupSourceReq; +import android.system.StructLinger; +import android.system.StructPasswd; +import android.system.StructPollfd; +import android.system.StructStat; +import android.system.StructStatVfs; +import android.system.StructTimeval; +import android.system.StructUcred; +import android.system.StructUtsname; +import android.util.MutableInt; +import android.util.MutableLong; import java.io.FileDescriptor; import java.io.InterruptedIOException; import java.net.InetAddress; @@ -23,8 +39,6 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.SocketException; import java.nio.ByteBuffer; -import libcore.util.MutableInt; -import libcore.util.MutableLong; /** * Subclass this if you want to override some {@link Os} methods but otherwise delegate. diff --git a/luni/src/main/java/libcore/io/GaiException.java b/luni/src/main/java/libcore/io/GaiException.java deleted file mode 100644 index 08143dc..0000000 --- a/luni/src/main/java/libcore/io/GaiException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package libcore.io; - -import java.net.UnknownHostException; -import libcore.io.OsConstants; - -/** - * An unchecked exception thrown when the {@link Os} {@code getaddrinfo} or {@code getnameinfo} - * methods fail. This exception contains the native error value, for comparison against the - * {@code GAI_} constants in {@link OsConstants}, should sophisticated - * callers need to adjust their behavior based on the exact failure. - */ -public final class GaiException extends RuntimeException { - private final String functionName; - public final int error; - - public GaiException(String functionName, int error) { - this.functionName = functionName; - this.error = error; - } - - public GaiException(String functionName, int error, Throwable cause) { - super(cause); - this.functionName = functionName; - this.error = error; - } - - /** - * Converts the stashed function name and error value to a human-readable string. - * We do this here rather than in the constructor so that callers only pay for - * this if they need it. - */ - @Override public String getMessage() { - String gaiName = OsConstants.gaiName(error); - if (gaiName == null) { - gaiName = "GAI_ error " + error; - } - String description = Libcore.os.gai_strerror(error); - return functionName + " failed: " + gaiName + " (" + description + ")"; - } - - public UnknownHostException rethrowAsUnknownHostException(String detailMessage) throws UnknownHostException { - UnknownHostException newException = new UnknownHostException(detailMessage); - newException.initCause(this); - throw newException; - } - - public UnknownHostException rethrowAsUnknownHostException() throws UnknownHostException { - throw rethrowAsUnknownHostException(getMessage()); - } -} diff --git a/luni/src/main/java/libcore/io/IoBridge.java b/luni/src/main/java/libcore/io/IoBridge.java index 89070cd..1e2ed7d 100644 --- a/luni/src/main/java/libcore/io/IoBridge.java +++ b/luni/src/main/java/libcore/io/IoBridge.java @@ -16,6 +16,12 @@ package libcore.io; +import android.system.StructGroupReq; +import android.system.StructGroupSourceReq; +import android.system.StructLinger; +import android.system.StructPollfd; +import android.system.StructTimeval; +import android.util.MutableInt; import java.io.FileDescriptor; import java.io.FileNotFoundException; import java.io.IOException; @@ -35,8 +41,7 @@ import java.net.SocketTimeoutException; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.util.Arrays; -import static libcore.io.OsConstants.*; -import libcore.util.MutableInt; +import static android.system.OsConstants.*; /** * Implements java.io/java.net/java.nio semantics in terms of the underlying POSIX system calls. diff --git a/luni/src/main/java/libcore/io/IoUtils.java b/luni/src/main/java/libcore/io/IoUtils.java index 10ef671..27da93f 100644 --- a/luni/src/main/java/libcore/io/IoUtils.java +++ b/luni/src/main/java/libcore/io/IoUtils.java @@ -25,7 +25,7 @@ import java.net.Socket; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Random; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; public final class IoUtils { private static final Random TEMPORARY_DIRECTORY_PRNG = new Random(); diff --git a/luni/src/main/java/libcore/io/MemoryMappedFile.java b/luni/src/main/java/libcore/io/MemoryMappedFile.java index 2d8aa2b..b4cd8fc 100644 --- a/luni/src/main/java/libcore/io/MemoryMappedFile.java +++ b/luni/src/main/java/libcore/io/MemoryMappedFile.java @@ -16,16 +16,16 @@ package libcore.io; +import android.system.ErrnoException; import java.io.FileDescriptor; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteOrder; -import java.nio.NioUtils; import java.nio.channels.FileChannel; -import libcore.io.ErrnoException; +import java.nio.NioUtils; import libcore.io.Libcore; import libcore.io.Memory; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; /** * A memory-mapped file. Use {@link #mmap} to map a file, {@link #close} to unmap a file, diff --git a/luni/src/main/java/libcore/io/Os.java b/luni/src/main/java/libcore/io/Os.java index 2065c70..7a71261 100644 --- a/luni/src/main/java/libcore/io/Os.java +++ b/luni/src/main/java/libcore/io/Os.java @@ -16,6 +16,22 @@ package libcore.io; +import android.system.ErrnoException; +import android.system.GaiException; +import android.system.StructAddrinfo; +import android.system.StructFlock; +import android.system.StructGroupReq; +import android.system.StructGroupSourceReq; +import android.system.StructLinger; +import android.system.StructPasswd; +import android.system.StructPollfd; +import android.system.StructStat; +import android.system.StructStatVfs; +import android.system.StructTimeval; +import android.system.StructUcred; +import android.system.StructUtsname; +import android.util.MutableInt; +import android.util.MutableLong; import java.io.FileDescriptor; import java.io.InterruptedIOException; import java.net.InetAddress; @@ -23,8 +39,6 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.SocketException; import java.nio.ByteBuffer; -import libcore.util.MutableInt; -import libcore.util.MutableLong; public interface Os { public FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException; diff --git a/luni/src/main/java/libcore/io/OsConstants.java b/luni/src/main/java/libcore/io/OsConstants.java index 49b0182..2c97122 100644 --- a/luni/src/main/java/libcore/io/OsConstants.java +++ b/luni/src/main/java/libcore/io/OsConstants.java @@ -16,8 +16,9 @@ package libcore.io; -public final class OsConstants { - private OsConstants() { } +public /* Not final because of android.system.OsConstants */ class OsConstants { + // So android.system.OsConstants can subclass us. + protected OsConstants() { } public static boolean S_ISBLK(int mode) { return (mode & S_IFMT) == S_IFBLK; } public static boolean S_ISCHR(int mode) { return (mode & S_IFMT) == S_IFCHR; } diff --git a/luni/src/main/java/libcore/io/Posix.java b/luni/src/main/java/libcore/io/Posix.java index a5c3eb0..c2dccce 100644 --- a/luni/src/main/java/libcore/io/Posix.java +++ b/luni/src/main/java/libcore/io/Posix.java @@ -16,6 +16,22 @@ package libcore.io; +import android.system.ErrnoException; +import android.system.GaiException; +import android.system.StructAddrinfo; +import android.system.StructFlock; +import android.system.StructGroupReq; +import android.system.StructGroupSourceReq; +import android.system.StructLinger; +import android.system.StructPasswd; +import android.system.StructPollfd; +import android.system.StructStat; +import android.system.StructStatVfs; +import android.system.StructTimeval; +import android.system.StructUcred; +import android.system.StructUtsname; +import android.util.MutableInt; +import android.util.MutableLong; import java.io.FileDescriptor; import java.io.InterruptedIOException; import java.net.InetAddress; @@ -24,8 +40,6 @@ import java.net.SocketAddress; import java.net.SocketException; import java.nio.ByteBuffer; import java.nio.NioUtils; -import libcore.util.MutableInt; -import libcore.util.MutableLong; public final class Posix implements Os { Posix() { } diff --git a/luni/src/main/java/libcore/io/StructStat.java b/luni/src/main/java/libcore/io/StructStat.java index 00371fb..29685c6 100644 --- a/luni/src/main/java/libcore/io/StructStat.java +++ b/luni/src/main/java/libcore/io/StructStat.java @@ -21,7 +21,7 @@ package libcore.io; * {@code struct stat} from * <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html"><stat.h></a> */ -public final class StructStat { +public /* not final for android.system.StructStat */ class StructStat { /** Device ID of device containing file. */ public final long st_dev; /*dev_t*/ diff --git a/luni/src/main/java/libcore/io/StructStatVfs.java b/luni/src/main/java/libcore/io/StructStatVfs.java index bdff111..4beb69f 100644 --- a/luni/src/main/java/libcore/io/StructStatVfs.java +++ b/luni/src/main/java/libcore/io/StructStatVfs.java @@ -19,7 +19,7 @@ package libcore.io; /** * File information returned by fstatvfs(2) and statvfs(2). */ -public final class StructStatVfs { +public /* not final for android.system.StructStatVfs */ class StructStatVfs { /** File system block size (used for block counts). */ public final long f_bsize; /*unsigned long*/ diff --git a/luni/src/main/java/libcore/util/ZoneInfoDB.java b/luni/src/main/java/libcore/util/ZoneInfoDB.java index 10e3900..7ff377c 100644 --- a/luni/src/main/java/libcore/util/ZoneInfoDB.java +++ b/luni/src/main/java/libcore/util/ZoneInfoDB.java @@ -16,6 +16,7 @@ package libcore.util; +import android.system.ErrnoException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; @@ -27,7 +28,6 @@ import java.util.Arrays; import java.util.List; import java.util.TimeZone; import libcore.io.BufferIterator; -import libcore.io.ErrnoException; import libcore.io.IoUtils; import libcore.io.MemoryMappedFile; diff --git a/luni/src/main/native/libcore_io_Posix.cpp b/luni/src/main/native/libcore_io_Posix.cpp index 65ee36f..7fcec29 100644 --- a/luni/src/main/native/libcore_io_Posix.cpp +++ b/luni/src/main/native/libcore_io_Posix.cpp @@ -1025,7 +1025,7 @@ static jint Posix_poll(JNIEnv* env, jobject, jobjectArray javaStructs, jint time static jfieldID eventsFid = env->GetFieldID(JniConstants::structPollfdClass, "events", "S"); static jfieldID reventsFid = env->GetFieldID(JniConstants::structPollfdClass, "revents", "S"); - // Turn the Java libcore.io.StructPollfd[] into a C++ struct pollfd[]. + // Turn the Java android.system.StructPollfd[] into a C++ struct pollfd[]. size_t arrayLength = env->GetArrayLength(javaStructs); UniquePtr<struct pollfd[]> fds(new struct pollfd[arrayLength]); memset(fds.get(), 0, sizeof(struct pollfd) * arrayLength); @@ -1057,7 +1057,7 @@ static jint Posix_poll(JNIEnv* env, jobject, jobjectArray javaStructs, jint time return -1; } - // Update the revents fields in the Java libcore.io.StructPollfd[]. + // Update the revents fields in the Java android.system.StructPollfd[]. for (size_t i = 0; i < count; ++i) { ScopedLocalRef<jobject> javaStruct(env, env->GetObjectArrayElement(javaStructs, i)); if (javaStruct.get() == NULL) { @@ -1493,14 +1493,14 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(Posix, fchown, "(Ljava/io/FileDescriptor;II)V"), NATIVE_METHOD(Posix, fcntlVoid, "(Ljava/io/FileDescriptor;I)I"), NATIVE_METHOD(Posix, fcntlLong, "(Ljava/io/FileDescriptor;IJ)I"), - NATIVE_METHOD(Posix, fcntlFlock, "(Ljava/io/FileDescriptor;ILlibcore/io/StructFlock;)I"), + NATIVE_METHOD(Posix, fcntlFlock, "(Ljava/io/FileDescriptor;ILandroid/system/StructFlock;)I"), NATIVE_METHOD(Posix, fdatasync, "(Ljava/io/FileDescriptor;)V"), - NATIVE_METHOD(Posix, fstat, "(Ljava/io/FileDescriptor;)Llibcore/io/StructStat;"), - NATIVE_METHOD(Posix, fstatvfs, "(Ljava/io/FileDescriptor;)Llibcore/io/StructStatVfs;"), + NATIVE_METHOD(Posix, fstat, "(Ljava/io/FileDescriptor;)Landroid/system/StructStat;"), + NATIVE_METHOD(Posix, fstatvfs, "(Ljava/io/FileDescriptor;)Landroid/system/StructStatVfs;"), NATIVE_METHOD(Posix, fsync, "(Ljava/io/FileDescriptor;)V"), NATIVE_METHOD(Posix, ftruncate, "(Ljava/io/FileDescriptor;J)V"), NATIVE_METHOD(Posix, gai_strerror, "(I)Ljava/lang/String;"), - NATIVE_METHOD(Posix, getaddrinfo, "(Ljava/lang/String;Llibcore/io/StructAddrinfo;)[Ljava/net/InetAddress;"), + NATIVE_METHOD(Posix, getaddrinfo, "(Ljava/lang/String;Landroid/system/StructAddrinfo;)[Ljava/net/InetAddress;"), NATIVE_METHOD(Posix, getegid, "()I"), NATIVE_METHOD(Posix, geteuid, "()I"), NATIVE_METHOD(Posix, getgid, "()I"), @@ -1509,27 +1509,27 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(Posix, getpeername, "(Ljava/io/FileDescriptor;)Ljava/net/SocketAddress;"), NATIVE_METHOD(Posix, getpid, "()I"), NATIVE_METHOD(Posix, getppid, "()I"), - NATIVE_METHOD(Posix, getpwnam, "(Ljava/lang/String;)Llibcore/io/StructPasswd;"), - NATIVE_METHOD(Posix, getpwuid, "(I)Llibcore/io/StructPasswd;"), + NATIVE_METHOD(Posix, getpwnam, "(Ljava/lang/String;)Landroid/system/StructPasswd;"), + NATIVE_METHOD(Posix, getpwuid, "(I)Landroid/system/StructPasswd;"), NATIVE_METHOD(Posix, getsockname, "(Ljava/io/FileDescriptor;)Ljava/net/SocketAddress;"), NATIVE_METHOD(Posix, getsockoptByte, "(Ljava/io/FileDescriptor;II)I"), NATIVE_METHOD(Posix, getsockoptInAddr, "(Ljava/io/FileDescriptor;II)Ljava/net/InetAddress;"), NATIVE_METHOD(Posix, getsockoptInt, "(Ljava/io/FileDescriptor;II)I"), - NATIVE_METHOD(Posix, getsockoptLinger, "(Ljava/io/FileDescriptor;II)Llibcore/io/StructLinger;"), - NATIVE_METHOD(Posix, getsockoptTimeval, "(Ljava/io/FileDescriptor;II)Llibcore/io/StructTimeval;"), - NATIVE_METHOD(Posix, getsockoptUcred, "(Ljava/io/FileDescriptor;II)Llibcore/io/StructUcred;"), + NATIVE_METHOD(Posix, getsockoptLinger, "(Ljava/io/FileDescriptor;II)Landroid/system/StructLinger;"), + NATIVE_METHOD(Posix, getsockoptTimeval, "(Ljava/io/FileDescriptor;II)Landroid/system/StructTimeval;"), + NATIVE_METHOD(Posix, getsockoptUcred, "(Ljava/io/FileDescriptor;II)Landroid/system/StructUcred;"), NATIVE_METHOD(Posix, gettid, "()I"), NATIVE_METHOD(Posix, getuid, "()I"), NATIVE_METHOD(Posix, if_indextoname, "(I)Ljava/lang/String;"), NATIVE_METHOD(Posix, inet_pton, "(ILjava/lang/String;)Ljava/net/InetAddress;"), NATIVE_METHOD(Posix, ioctlInetAddress, "(Ljava/io/FileDescriptor;ILjava/lang/String;)Ljava/net/InetAddress;"), - NATIVE_METHOD(Posix, ioctlInt, "(Ljava/io/FileDescriptor;ILlibcore/util/MutableInt;)I"), + NATIVE_METHOD(Posix, ioctlInt, "(Ljava/io/FileDescriptor;ILandroid/util/MutableInt;)I"), NATIVE_METHOD(Posix, isatty, "(Ljava/io/FileDescriptor;)Z"), NATIVE_METHOD(Posix, kill, "(II)V"), NATIVE_METHOD(Posix, lchown, "(Ljava/lang/String;II)V"), NATIVE_METHOD(Posix, listen, "(Ljava/io/FileDescriptor;I)V"), NATIVE_METHOD(Posix, lseek, "(Ljava/io/FileDescriptor;JI)J"), - NATIVE_METHOD(Posix, lstat, "(Ljava/lang/String;)Llibcore/io/StructStat;"), + NATIVE_METHOD(Posix, lstat, "(Ljava/lang/String;)Landroid/system/StructStat;"), NATIVE_METHOD(Posix, mincore, "(JJ[B)V"), NATIVE_METHOD(Posix, mkdir, "(Ljava/lang/String;I)V"), NATIVE_METHOD(Posix, mkfifo, "(Ljava/lang/String;I)V"), @@ -1540,7 +1540,7 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(Posix, munmap, "(JJ)V"), NATIVE_METHOD(Posix, open, "(Ljava/lang/String;II)Ljava/io/FileDescriptor;"), NATIVE_METHOD(Posix, pipe, "()[Ljava/io/FileDescriptor;"), - NATIVE_METHOD(Posix, poll, "([Llibcore/io/StructPollfd;I)I"), + NATIVE_METHOD(Posix, poll, "([Landroid/system/StructPollfd;I)I"), NATIVE_METHOD(Posix, posix_fallocate, "(Ljava/io/FileDescriptor;JJ)V"), NATIVE_METHOD(Posix, preadBytes, "(Ljava/io/FileDescriptor;Ljava/lang/Object;IIJ)I"), NATIVE_METHOD(Posix, pwriteBytes, "(Ljava/io/FileDescriptor;Ljava/lang/Object;IIJ)I"), @@ -1550,7 +1550,7 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(Posix, recvfromBytes, "(Ljava/io/FileDescriptor;Ljava/lang/Object;IIILjava/net/InetSocketAddress;)I"), NATIVE_METHOD(Posix, remove, "(Ljava/lang/String;)V"), NATIVE_METHOD(Posix, rename, "(Ljava/lang/String;Ljava/lang/String;)V"), - NATIVE_METHOD(Posix, sendfile, "(Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Llibcore/util/MutableLong;J)J"), + NATIVE_METHOD(Posix, sendfile, "(Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Landroid/util/MutableLong;J)J"), NATIVE_METHOD(Posix, sendtoBytes, "(Ljava/io/FileDescriptor;Ljava/lang/Object;IIILjava/net/InetAddress;I)I"), NATIVE_METHOD(Posix, setegid, "(I)V"), NATIVE_METHOD(Posix, setenv, "(Ljava/lang/String;Ljava/lang/String;Z)V"), @@ -1561,16 +1561,16 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(Posix, setsockoptIfreq, "(Ljava/io/FileDescriptor;IILjava/lang/String;)V"), NATIVE_METHOD(Posix, setsockoptInt, "(Ljava/io/FileDescriptor;III)V"), NATIVE_METHOD(Posix, setsockoptIpMreqn, "(Ljava/io/FileDescriptor;III)V"), - NATIVE_METHOD(Posix, setsockoptGroupReq, "(Ljava/io/FileDescriptor;IILlibcore/io/StructGroupReq;)V"), - NATIVE_METHOD(Posix, setsockoptGroupSourceReq, "(Ljava/io/FileDescriptor;IILlibcore/io/StructGroupSourceReq;)V"), - NATIVE_METHOD(Posix, setsockoptLinger, "(Ljava/io/FileDescriptor;IILlibcore/io/StructLinger;)V"), - NATIVE_METHOD(Posix, setsockoptTimeval, "(Ljava/io/FileDescriptor;IILlibcore/io/StructTimeval;)V"), + NATIVE_METHOD(Posix, setsockoptGroupReq, "(Ljava/io/FileDescriptor;IILandroid/system/StructGroupReq;)V"), + NATIVE_METHOD(Posix, setsockoptGroupSourceReq, "(Ljava/io/FileDescriptor;IILandroid/system/StructGroupSourceReq;)V"), + NATIVE_METHOD(Posix, setsockoptLinger, "(Ljava/io/FileDescriptor;IILandroid/system/StructLinger;)V"), + NATIVE_METHOD(Posix, setsockoptTimeval, "(Ljava/io/FileDescriptor;IILandroid/system/StructTimeval;)V"), NATIVE_METHOD(Posix, setuid, "(I)V"), NATIVE_METHOD(Posix, shutdown, "(Ljava/io/FileDescriptor;I)V"), NATIVE_METHOD(Posix, socket, "(III)Ljava/io/FileDescriptor;"), NATIVE_METHOD(Posix, socketpair, "(IIILjava/io/FileDescriptor;Ljava/io/FileDescriptor;)V"), - NATIVE_METHOD(Posix, stat, "(Ljava/lang/String;)Llibcore/io/StructStat;"), - NATIVE_METHOD(Posix, statvfs, "(Ljava/lang/String;)Llibcore/io/StructStatVfs;"), + NATIVE_METHOD(Posix, stat, "(Ljava/lang/String;)Landroid/system/StructStat;"), + NATIVE_METHOD(Posix, statvfs, "(Ljava/lang/String;)Landroid/system/StructStatVfs;"), NATIVE_METHOD(Posix, strerror, "(I)Ljava/lang/String;"), NATIVE_METHOD(Posix, strsignal, "(I)Ljava/lang/String;"), NATIVE_METHOD(Posix, symlink, "(Ljava/lang/String;Ljava/lang/String;)V"), @@ -1578,9 +1578,9 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(Posix, tcdrain, "(Ljava/io/FileDescriptor;)V"), NATIVE_METHOD(Posix, tcsendbreak, "(Ljava/io/FileDescriptor;I)V"), NATIVE_METHOD(Posix, umaskImpl, "(I)I"), - NATIVE_METHOD(Posix, uname, "()Llibcore/io/StructUtsname;"), + NATIVE_METHOD(Posix, uname, "()Landroid/system/StructUtsname;"), NATIVE_METHOD(Posix, unsetenv, "(Ljava/lang/String;)V"), - NATIVE_METHOD(Posix, waitpid, "(ILlibcore/util/MutableInt;I)I"), + NATIVE_METHOD(Posix, waitpid, "(ILandroid/util/MutableInt;I)I"), NATIVE_METHOD(Posix, writeBytes, "(Ljava/io/FileDescriptor;Ljava/lang/Object;II)I"), NATIVE_METHOD(Posix, writev, "(Ljava/io/FileDescriptor;[Ljava/lang/Object;[I[I)I"), }; diff --git a/luni/src/test/java/libcore/io/OsTest.java b/luni/src/test/java/libcore/io/OsTest.java index 624c119..cf28122 100644 --- a/luni/src/test/java/libcore/io/OsTest.java +++ b/luni/src/test/java/libcore/io/OsTest.java @@ -16,6 +16,7 @@ package libcore.io; +import android.system.StructUcred; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; @@ -26,8 +27,7 @@ import java.net.ServerSocket; import java.net.SocketAddress; import java.util.Locale; import junit.framework.TestCase; - -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; public class OsTest extends TestCase { public void testIsSocket() throws Exception { diff --git a/luni/src/test/java/libcore/java/nio/channels/FileIOInterruptTest.java b/luni/src/test/java/libcore/java/nio/channels/FileIOInterruptTest.java index 2ac8827..c06df04 100644 --- a/luni/src/test/java/libcore/java/nio/channels/FileIOInterruptTest.java +++ b/luni/src/test/java/libcore/java/nio/channels/FileIOInterruptTest.java @@ -17,19 +17,19 @@ package libcore.java.nio.channels; import junit.framework.TestCase; +import android.system.ErrnoException; +import android.system.OsConstants; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InterruptedIOException; +import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.AsynchronousCloseException; import java.nio.channels.ClosedByInterruptException; import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; -import libcore.io.ErrnoException; import libcore.io.Libcore; -import libcore.io.OsConstants; import static libcore.io.IoUtils.closeQuietly; diff --git a/luni/src/test/java/libcore/java/nio/channels/SelectorTest.java b/luni/src/test/java/libcore/java/nio/channels/SelectorTest.java index 24751c2..c5f449e 100644 --- a/luni/src/test/java/libcore/java/nio/channels/SelectorTest.java +++ b/luni/src/test/java/libcore/java/nio/channels/SelectorTest.java @@ -15,6 +15,7 @@ */ package libcore.java.nio.channels; +import android.system.OsConstants; import java.io.IOException; import java.net.InetSocketAddress; import java.net.ServerSocket; @@ -26,9 +27,8 @@ import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import libcore.io.Libcore; -import libcore.io.OsConstants; import junit.framework.TestCase; +import libcore.io.Libcore; import tests.net.StuckServer; public class SelectorTest extends TestCase { diff --git a/luni/src/test/java/libcore/java/nio/channels/SocketChannelTest.java b/luni/src/test/java/libcore/java/nio/channels/SocketChannelTest.java index bd23b3f..6bba862 100644 --- a/luni/src/test/java/libcore/java/nio/channels/SocketChannelTest.java +++ b/luni/src/test/java/libcore/java/nio/channels/SocketChannelTest.java @@ -36,7 +36,7 @@ import java.util.Set; import tests.io.MockOs; -import static libcore.io.OsConstants.*; +import static android.system.OsConstants.*; public class SocketChannelTest extends junit.framework.TestCase { diff --git a/support/src/test/java/tests/io/MockOs.java b/support/src/test/java/tests/io/MockOs.java index d7e284f..b1c6cee 100644 --- a/support/src/test/java/tests/io/MockOs.java +++ b/support/src/test/java/tests/io/MockOs.java @@ -16,6 +16,8 @@ package tests.io; +import android.system.ErrnoException; +import android.system.OsConstants; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -24,10 +26,8 @@ import java.util.ArrayDeque; import java.util.Deque; import java.util.HashMap; import java.util.Map; -import libcore.io.ErrnoException; import libcore.io.Libcore; import libcore.io.Os; -import libcore.io.OsConstants; /** * A mocking interceptor that wraps another {@link Os} to add faults. This can |