diff options
Diffstat (limited to 'libjava/classpath/vm/reference/gnu/java')
15 files changed, 229 insertions, 230 deletions
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/VMCPStringBuilder.java b/libjava/classpath/vm/reference/gnu/java/lang/VMCPStringBuilder.java index 8e137cd3fec..c3a3784f398 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/VMCPStringBuilder.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/VMCPStringBuilder.java @@ -59,16 +59,16 @@ final class VMCPStringBuilder { try { - cons = String.class.getDeclaredConstructor(new Class[] { char[].class, - Integer.TYPE, - Integer.TYPE, - Boolean.TYPE }); - cons.setAccessible(true); + cons = String.class.getDeclaredConstructor(new Class[] { char[].class, + Integer.TYPE, + Integer.TYPE, + Boolean.TYPE }); + cons.setAccessible(true); } catch (NoSuchMethodException e) { - throw (Error) - new InternalError("Could not get no-copy String constructor").initCause(e); + throw (Error) + new InternalError("Could not get no-copy String constructor").initCause(e); } } @@ -87,25 +87,25 @@ final class VMCPStringBuilder { try { - return (String) - cons.newInstance(new Object[] { value, Integer.valueOf(startIndex), - Integer.valueOf(count), - Boolean.valueOf(true) }); + return (String) + cons.newInstance(new Object[] { value, Integer.valueOf(startIndex), + Integer.valueOf(count), + Boolean.valueOf(true) }); } catch (InstantiationException e) { - throw (Error) - new InternalError("Could not instantiate no-copy String constructor").initCause(e); + throw (Error) + new InternalError("Could not instantiate no-copy String constructor").initCause(e); } catch (IllegalAccessException e) { - throw (Error) - new InternalError("Could not access no-copy String constructor").initCause(e); + throw (Error) + new InternalError("Could not access no-copy String constructor").initCause(e); } catch (InvocationTargetException e) { - throw (Error) - new InternalError("Error calling no-copy String constructor").initCause(e); + throw (Error) + new InternalError("Error calling no-copy String constructor").initCause(e); } } diff --git a/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java index eee94702d35..5501f0f7f5b 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java @@ -48,14 +48,14 @@ import java.lang.instrument.Instrumentation; */ final class VMInstrumentationImpl { - + /** * Returns if the current JVM supports class redefinition - * + * * @return true if the current JVM supports class redefinition */ static native boolean isRedefineClassesSupported(); - + /** * Redefines classes given as parameters. The method has to call * the callTransformers from InstrumentationImpl @@ -63,8 +63,8 @@ final class VMInstrumentationImpl * @param inst an instrumentation object * @param definitions an array of bytecode<->class correspondance * - * @throws ClassNotFoundException if a class cannot be found - * @throws UnmodifiableClassException if a class cannot be modified + * @throws ClassNotFoundException if a class cannot be found + * @throws UnmodifiableClassException if a class cannot be modified * @throws UnsupportedOperationException if the JVM does not support * redefinition or the redefinition made unsupported changes * @throws ClassFormatError if a class file is not valid @@ -74,14 +74,14 @@ final class VMInstrumentationImpl * are unsupported * @throws ClassCircularityError if circularity occured with the new * classes - * @throws LinkageError if a linkage error occurs + * @throws LinkageError if a linkage error occurs */ static native void redefineClasses(Instrumentation inst, ClassDefinition[] definitions); - + /** * Get all the classes loaded by the JVM. - * + * * @return an array containing all the classes loaded by the JVM. The array * is empty if no class is loaded. */ @@ -89,9 +89,9 @@ final class VMInstrumentationImpl /** * Get all the classes loaded by a given class loader - * + * * @param loader the loader - * + * * @return an array containing all the classes loaded by the given loader. * The array is empty if no class was loaded by the loader. */ @@ -99,7 +99,7 @@ final class VMInstrumentationImpl /** * Get the size of an object. The object is not null - * + * * @param objectToSize the object * @return the size of the object */ diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java index c1c7d13dd44..ea49897419b 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java @@ -38,7 +38,7 @@ exception statement from your version. */ package gnu.java.lang.management; /** - * Provides access to information about the class loading + * Provides access to information about the class loading * behaviour of the current invocation of the virtual * machine. Instances of this bean are obtained by calling * {@link ManagementFactory#getClassLoadingMXBean()}. diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java index b9b5bbcefc7..019af0ca411 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java @@ -38,7 +38,7 @@ exception statement from your version. */ package gnu.java.lang.management; /** - * Provides access to information about the JIT + * Provides access to information about the JIT * compiler of the virtual machine, if one exists. * Instances of this bean are obtained by calling * {@link ManagementFactory#getCompilationMXBean()}, diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java index 2a202849a8f..00861bc21de 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java @@ -70,7 +70,7 @@ final class VMGarbageCollectorMXBeanImpl * Note that the accumulated time may not change, even when the * collection count increases, if the time taken is sufficiently * short; this depends on the resolution of the timer used. - * + * * @param name the name of the garbage collector. * @return the accumulated number of milliseconds spent collecting, * or -1 if this is undefined. diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java index eade26374db..7f69bdfb741 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java @@ -126,29 +126,29 @@ final class VMMemoryMXBeanImpl ManagementFactory.getMemoryPoolMXBeans().iterator(); while (pools.hasNext()) { - MemoryPoolMXBean pool = (MemoryPoolMXBean) pools.next(); - if (pool.getType() == type) - { - MemoryUsage usage = pool.getUsage(); - if (init != -1) - { - long poolInit = usage.getInit(); - if (poolInit == -1) - init = -1; - else - init += poolInit; - } - committed += usage.getCommitted(); - used += usage.getUsed(); - if (max != -1) - { - long poolMax = usage.getMax(); - if (poolMax == -1) - max = -1; - else - max += poolMax; - } - } + MemoryPoolMXBean pool = (MemoryPoolMXBean) pools.next(); + if (pool.getType() == type) + { + MemoryUsage usage = pool.getUsage(); + if (init != -1) + { + long poolInit = usage.getInit(); + if (poolInit == -1) + init = -1; + else + init += poolInit; + } + committed += usage.getCommitted(); + used += usage.getUsed(); + if (max != -1) + { + long poolMax = usage.getMax(); + if (poolMax == -1) + max = -1; + else + max += poolMax; + } + } } return new MemoryUsage(init, used, committed, max); } diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java index 0a4204a6d57..477329f0aed 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java @@ -56,10 +56,10 @@ import java.util.List; final class VMMemoryManagerMXBeanImpl { - /** + /** * Returns an array containing the names of the memory pools * this memory manager manages. - * + * * @param name the name of the memory manager. * @return an array containing the name of each memory pool * this manager is responsible for. @@ -70,14 +70,14 @@ final class VMMemoryManagerMXBeanImpl Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator(); while (beans.hasNext()) { - MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next(); - String[] managers = bean.getMemoryManagerNames(); - for (int a = 0; a < managers.length; ++a) - if (managers[a].equals(name)) - { - managedPools.add(bean.getName()); - break; - } + MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next(); + String[] managers = bean.getMemoryManagerNames(); + for (int a = 0; a < managers.length; ++a) + if (managers[a].equals(name)) + { + managedPools.add(bean.getName()); + break; + } } return (String[]) managedPools.toArray(new String[managedPools.size()]); } diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java index 723d4e89713..36cd2586a8e 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java @@ -106,7 +106,7 @@ final class VMMemoryPoolMXBeanImpl static native MemoryUsage getPeakUsage(String name); /** - * Returns the type of memory used by the specified pool. + * Returns the type of memory used by the specified pool. * The value must be either "HEAP" or "NON_HEAP". * * @param name the name of the pool to obtain statistics on. @@ -149,7 +149,7 @@ final class VMMemoryPoolMXBeanImpl * @return the usage threshold count. */ static native long getUsageThresholdCount(String name); - + /** * Returns true if the specified pool is still valid i.e. * it is still in use by the virtual machine. @@ -158,7 +158,7 @@ final class VMMemoryPoolMXBeanImpl * @return true if the pool is valid. */ static native boolean isValid(String name); - + /** * Resets the peak usage level to the current usage level for * the specified pool. @@ -173,7 +173,7 @@ final class VMMemoryPoolMXBeanImpl * This is only called if this functionality is supported * by the virtual machine (i.e. the appropriate property, * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>, - * is defined). + * is defined). * * @param name the name of the pool to set the threshold of. * @param threshold the new threshold level. @@ -185,7 +185,7 @@ final class VMMemoryPoolMXBeanImpl * This is only called if this functionality is supported * by the virtual machine (i.e. the appropriate property, * <code>gnu.java.lang.management.UsageThresholdSupport</code>, - * is defined). + * is defined). * * @param name the name of the pool to set the threshold of. * @param threshold the new threshold level. diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java index 1c061aa9356..33448d9d534 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java @@ -40,7 +40,7 @@ package gnu.java.lang.management; import java.lang.management.ThreadInfo; /** - * Provides access to information about the threads + * Provides access to information about the threads * of the virtual machine. An instance of this bean is * obtained by calling * {@link ManagementFactory#getThreadMXBean()}. @@ -87,13 +87,13 @@ final class VMThreadMXBeanImpl filled = group.enumerate(threadList); while (filled == arraySize) { - arraySize *= 2; - threadList = new Thread[arraySize]; - filled = group.enumerate(threadList); + arraySize *= 2; + threadList = new Thread[arraySize]; + filled = group.enumerate(threadList); } return threadList; } - + /** * Returns the id of all live threads at the time of execution. * @@ -141,8 +141,8 @@ final class VMThreadMXBeanImpl int daemonCount = 0; for (int a = 0; a < filled; ++a) { - if (threadList[a].isDaemon()) - ++daemonCount; + if (threadList[a].isDaemon()) + ++daemonCount; } return daemonCount; } @@ -205,7 +205,7 @@ final class VMThreadMXBeanImpl * @return the corresponding <code>ThreadInfo</code>. */ static native ThreadInfo getThreadInfoForId(long id, int maxDepth); - + /** * Returns the number of nanoseconds of user time * the specified thread has used in total. This is @@ -217,7 +217,7 @@ final class VMThreadMXBeanImpl * the thread. */ static native long getThreadUserTime(long id); - + /** * Returns the total number of threads that have * been started over the lifetime of the virtual diff --git a/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java b/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java index 958c2187412..da0f893cfbc 100644 --- a/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -69,7 +69,7 @@ public final class VMPlainDatagramSocketImpl System.loadLibrary("javanet"); } } - + /** * Binds this socket to a particular port and interface * @@ -78,9 +78,9 @@ public final class VMPlainDatagramSocketImpl * @param addr the address to bind to * * @throws SocketException If an error occurs - */ + */ static native void bind(PlainDatagramSocketImpl socket, int port, - InetAddress addr) + InetAddress addr) throws SocketException; /** @@ -127,7 +127,7 @@ public final class VMPlainDatagramSocketImpl * * @param socket the socket object * @param addr the address to send to - * @param port the port to send to + * @param port the port to send to * @param buf the buffer to send * @param offset the offset of the data in the buffer to send * @param len the length of the data to send diff --git a/libjava/classpath/vm/reference/gnu/java/net/VMPlainSocketImpl.java b/libjava/classpath/vm/reference/gnu/java/net/VMPlainSocketImpl.java index 916f9593087..c72e6a5eb21 100644 --- a/libjava/classpath/vm/reference/gnu/java/net/VMPlainSocketImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/net/VMPlainSocketImpl.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -62,7 +62,7 @@ public final class VMPlainSocketImpl private static final int CP_IP_TTL = 0x1E61; private final State nfd; - + /** * Static initializer to load native library. */ @@ -73,19 +73,19 @@ public final class VMPlainSocketImpl System.loadLibrary("javanet"); } } - + public VMPlainSocketImpl() { // XXX consider adding security check here. nfd = new State(); } - + public VMPlainSocketImpl(VMChannel channel) throws IOException { this(); nfd.setChannelFD(channel.getState()); } - + public State getState() { return nfd; @@ -144,7 +144,7 @@ public final class VMPlainSocketImpl else throw new IllegalArgumentException("option value type " + optionValue.getClass().getName()); - + try { setOption(nfd.getNativeFD(), optionId, value); @@ -156,7 +156,7 @@ public final class VMPlainSocketImpl throw se; } } - + private static native void setOption(int fd, int id, int value) throws SocketException; @@ -198,16 +198,16 @@ public final class VMPlainSocketImpl /** * Get a socket option. This implementation is only required to support * socket options that are boolean values, which include: - * + * * SocketOptions.IP_MULTICAST_LOOP * SocketOptions.SO_BROADCAST * SocketOptions.SO_KEEPALIVE * SocketOptions.SO_OOBINLINE * SocketOptions.SO_REUSEADDR * SocketOptions.TCP_NODELAY - * + * * and socket options that are integer values, which include: - * + * * SocketOptions.IP_TOS * SocketOptions.SO_LINGER * SocketOptions.SO_RCVBUF @@ -232,7 +232,7 @@ public final class VMPlainSocketImpl se.initCause(ioe); throw se; } - + switch (optionId) { case SocketOptions.IP_MULTICAST_LOOP: @@ -242,20 +242,20 @@ public final class VMPlainSocketImpl case SocketOptions.SO_REUSEADDR: case SocketOptions.TCP_NODELAY: return Boolean.valueOf(value != 0); - + case SocketOptions.IP_TOS: case SocketOptions.SO_LINGER: case SocketOptions.SO_RCVBUF: case SocketOptions.SO_SNDBUF: case SocketOptions.SO_TIMEOUT: return new Integer(value); - + default: throw new SocketException("getting option " + optionId + " not supported here"); } } - + private static native int getOption(int fd, int id) throws SocketException; /** @@ -264,7 +264,7 @@ public final class VMPlainSocketImpl * * The optionId is provided to make it possible that the native * implementation may do something different depending on whether - * the value is SocketOptions.IP_MULTICAST_IF or + * the value is SocketOptions.IP_MULTICAST_IF or * SocketOptions.IP_MULTICAST_IF2. */ public InetAddress getMulticastInterface(int optionId) @@ -284,7 +284,7 @@ public final class VMPlainSocketImpl private static native InetAddress getMulticastInterface(int fd, int optionId); - + /** * Binds this socket to the given local address and port. * @@ -306,11 +306,11 @@ public final class VMPlainSocketImpl else throw new SocketException ("unsupported address type"); } - + /** * Native bind function for IPv4 addresses. The addr array must be * exactly four bytes long. - * + * * VMs without native support need not implement this. * * @param fd The native file descriptor integer. @@ -320,11 +320,11 @@ public final class VMPlainSocketImpl */ private static native void bind(int fd, byte[] addr, int port) throws IOException; - + /** * Native bind function for IPv6 addresses. The addr array must be * exactly sixteen bytes long. - * + * * VMs without native support need not implement this. * * @param fd The native file descriptor integer. @@ -346,7 +346,7 @@ public final class VMPlainSocketImpl { listen(nfd.getNativeFD(), backlog); } - + /** * Native listen function. VMs without native support need not implement * this. @@ -366,11 +366,11 @@ public final class VMPlainSocketImpl else throw new IllegalArgumentException("unknown address type"); } - + private static native void join(int fd, byte[] addr) throws IOException; - + private static native void join6(int fd, byte[] addr) throws IOException; - + public void leave(InetAddress group) throws IOException { if (group instanceof Inet4Address) @@ -380,16 +380,16 @@ public final class VMPlainSocketImpl else throw new IllegalArgumentException("unknown address type"); } - + private static native void leave(int fd, byte[] addr) throws IOException; - + private static native void leave6(int fd, byte[] addr) throws IOException; public void joinGroup(InetSocketAddress addr, NetworkInterface netif) throws IOException { InetAddress address = addr.getAddress(); - + if (address instanceof Inet4Address) joinGroup(nfd.getNativeFD(), address.getAddress(), netif != null ? netif.getName() : null); @@ -399,13 +399,13 @@ public final class VMPlainSocketImpl else throw new IllegalArgumentException("unknown address type"); } - + private static native void joinGroup(int fd, byte[] addr, String ifname) throws IOException; - + private static native void joinGroup6(int fd, byte[] addr, String ifname) throws IOException; - + public void leaveGroup(InetSocketAddress addr, NetworkInterface netif) throws IOException { @@ -419,42 +419,42 @@ public final class VMPlainSocketImpl else throw new IllegalArgumentException("unknown address type"); } - + private static native void leaveGroup(int fd, byte[] addr, String ifname) throws IOException; - + private static native void leaveGroup6(int fd, byte[] addr, String ifname) throws IOException; - - + + public void shutdownInput() throws IOException { shutdownInput(nfd.getNativeFD()); } - + private static native void shutdownInput(int native_fd) throws IOException; - + public void shutdownOutput() throws IOException { shutdownOutput(nfd.getNativeFD()); } - + private static native void shutdownOutput(int native_fd) throws IOException; - + public void sendUrgentData(int data) throws IOException { sendUrgentData(nfd.getNativeFD(), data); } - + private static native void sendUrgentData(int natfive_fd, int data) throws IOException; - + public void close() throws IOException { nfd.close(); } - + // Inner classes. - + /** * Our wrapper for the native file descriptor. In this implementation, * it is a simple wrapper around {@link VMChannel.State}, to simplify @@ -463,38 +463,38 @@ public final class VMPlainSocketImpl public final class State { private VMChannel.State channelFd; - + State() { channelFd = null; } - + public boolean isValid() { if (channelFd != null) return channelFd.isValid(); return false; } - + public int getNativeFD() throws IOException { return channelFd.getNativeFD(); } - + public void setChannelFD(final VMChannel.State nfd) throws IOException { if (this.channelFd != null && this.channelFd.isValid()) throw new IOException("file descriptor already initialized"); this.channelFd = nfd; } - + public void close() throws IOException { if (channelFd == null) throw new IOException("invalid file descriptor"); channelFd.close(); } - + protected void finalize() throws Throwable { try @@ -509,4 +509,3 @@ public final class VMPlainSocketImpl } } } - diff --git a/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java b/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java index a9d1452b72d..4494ff13ca4 100644 --- a/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java +++ b/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java @@ -53,7 +53,7 @@ import java.nio.MappedByteBuffer; /** * Native interface to support configuring of channel to run in a non-blocking * manner and support scatter/gather io operations. - * + * * @author Michael Barker <mike@middlesoft.co.uk> * */ @@ -61,12 +61,12 @@ public final class VMChannel { /** * Our reference implementation uses an integer to store the native - * file descriptor. Implementations without such support + * file descriptor. Implementations without such support */ private final State nfd; - + private Kind kind; - + public VMChannel() { // XXX consider adding security check here, so only Classpath @@ -74,14 +74,14 @@ public final class VMChannel this.nfd = new State(); kind = Kind.OTHER; } - + /** * This constructor is used by the POSIX reference implementation; * other virtual machines need not support it. - * + * * <strong>Important:</strong> do not call this in library code that is * not specific to Classpath's reference implementation. - * + * * @param native_fd The native file descriptor integer. * @throws IOException */ @@ -90,7 +90,7 @@ public final class VMChannel this(); this.nfd.setNativeFD(native_fd); } - + public State getState() { return nfd; @@ -105,62 +105,62 @@ public final class VMChannel } initIDs(); } - + public static VMChannel getStdin() throws IOException { return new VMChannel(stdin_fd()); } - + public static VMChannel getStdout() throws IOException { return new VMChannel(stdout_fd()); } - + public static VMChannel getStderr() throws IOException { return new VMChannel(stderr_fd()); } - + private static native int stdin_fd(); private static native int stdout_fd(); private static native int stderr_fd(); - + /** * Set the file descriptor to have the required blocking * setting. - * + * * @param blocking The blocking flag to set. */ public void setBlocking(boolean blocking) throws IOException { setBlocking(nfd.getNativeFD(), blocking); } - + private static native void setBlocking(int fd, boolean blocking) throws IOException; - + public int available() throws IOException { return available(nfd.getNativeFD()); } - + private static native int available(int native_fd) throws IOException; /** * Reads a byte buffer directly using the supplied file descriptor. - * + * * @param dst Direct Byte Buffer to read to. * @return Number of bytes read. - * @throws IOException If an error occurs or dst is not a direct buffers. + * @throws IOException If an error occurs or dst is not a direct buffers. */ public int read(ByteBuffer dst) throws IOException { return read(nfd.getNativeFD(), dst); } - + private static native int read(int fd, ByteBuffer dst) throws IOException; - + /** * Read a single byte. * @@ -171,19 +171,19 @@ public final class VMChannel { return read(nfd.getNativeFD()); } - + private static native int read(int fd) throws IOException; - + /** * Reads into byte buffers directly using the supplied file descriptor. * Assumes that the buffer list contains DirectBuffers. Will perform a * scattering read. - * + * * @param dsts An array direct byte buffers. * @param offset Index of the first buffer to read to. * @param length The number of buffers to read to. * @return Number of bytes read. - * @throws IOException If an error occurs or the dsts are not direct buffers. + * @throws IOException If an error occurs or the dsts are not direct buffers. */ public long readScattering(ByteBuffer[] dsts, int offset, int length) throws IOException @@ -193,11 +193,11 @@ public final class VMChannel return readScattering(nfd.getNativeFD(), dsts, offset, length); } - + private static native long readScattering(int fd, ByteBuffer[] dsts, int offset, int length) throws IOException; - + /** * Receive a datagram on this channel, returning the host address * that sent the datagram. @@ -228,18 +228,18 @@ public final class VMChannel int port = hostPort.getShort() & 0xFFFF; return new InetSocketAddress(Inet6Address.getByAddress(addr), port); } - + throw new SocketException("host address received with invalid length: " + hostlen); } - + private static native int receive (int fd, ByteBuffer dst, ByteBuffer address) throws IOException; /** * Writes from a direct byte bufer using the supplied file descriptor. * Assumes the buffer is a DirectBuffer. - * + * * @param src The source buffer. * @return Number of bytes written. * @throws IOException @@ -248,14 +248,14 @@ public final class VMChannel { return write(nfd.getNativeFD(), src); } - + private native int write(int fd, ByteBuffer src) throws IOException; /** * Writes from byte buffers directly using the supplied file descriptor. * Assumes the that buffer list constains DirectBuffers. Will perform * as gathering write. - * + * * @param srcs * @param offset * @param length @@ -267,13 +267,13 @@ public final class VMChannel { if (offset + length > srcs.length) throw new IndexOutOfBoundsException("offset + length > srcs.length"); - + // A gathering write is limited to 16 buffers; when writing, ensure // that we have at least one buffer with something in it in the 16 // buffer window starting at offset. while (!srcs[offset].hasRemaining() && offset < srcs.length) offset++; - + // There are no buffers with anything to write. if (offset == srcs.length) return 0; @@ -285,11 +285,11 @@ public final class VMChannel return writeGathering(nfd.getNativeFD(), srcs, offset, length); } - + private native long writeGathering(int fd, ByteBuffer[] srcs, int offset, int length) throws IOException; - + /** * Send a datagram to the given address. * @@ -311,15 +311,15 @@ public final class VMChannel else throw new SocketException("unrecognized inet address type"); } - + // Send to an IPv4 address. private static native int send(int fd, ByteBuffer src, byte[] addr, int port) throws IOException; - + // Send to an IPv6 address. private static native int send6(int fd, ByteBuffer src, byte[] addr, int port) throws IOException; - + /** * Write a single byte. * @@ -330,13 +330,13 @@ public final class VMChannel { write(nfd.getNativeFD(), b); } - + private static native void write(int fd, int b) throws IOException; - + private native static void initIDs(); // Network (socket) specific methods. - + /** * Create a new socket. This method will initialize the native file * descriptor state of this instance. @@ -356,7 +356,7 @@ public final class VMChannel kind = Kind.SOCK_DGRAM; nfd.setNativeFD(socket(stream)); } - + /** * Create a new socket, returning the native file descriptor. * @@ -382,7 +382,7 @@ public final class VMChannel int fd; InetAddress addr = saddr.getAddress(); - + // Translates an IOException into a SocketException to conform // to the throws clause. try @@ -402,13 +402,13 @@ public final class VMChannel timeout); throw new SocketException("unsupported internet address"); } - + private static native boolean connect(int fd, byte[] addr, int port, int timeout) throws SocketException; - + private static native boolean connect6(int fd, byte[] addr, int port, int timeout) throws SocketException; - + /** * Disconnect this channel, if it is a datagram socket. Disconnecting * a datagram channel will disassociate it from any address, so the @@ -424,9 +424,9 @@ public final class VMChannel throw new IOException("can only disconnect datagram channels"); disconnect(nfd.getNativeFD()); } - + private static native void disconnect(int fd) throws IOException; - + public InetSocketAddress getLocalAddress() throws IOException { if (!nfd.isValid()) @@ -451,7 +451,7 @@ public final class VMChannel } throw new SocketException("invalid address length"); } - + private static native int getsockname(int fd, ByteBuffer name) throws IOException; @@ -486,7 +486,7 @@ public final class VMChannel } throw new SocketException("invalid address length"); } - + /* * The format here is the peer address, followed by the port number. * The returned value is the length of the peer address; thus, there @@ -494,7 +494,7 @@ public final class VMChannel */ private static native int getpeername(int fd, ByteBuffer name) throws IOException; - + /** * Accept an incoming connection, returning a new VMChannel, or null * if the channel is nonblocking and no connection is pending. @@ -509,17 +509,17 @@ public final class VMChannel return null; return new VMChannel(new_fd); } - + private static native int accept(int native_fd) throws IOException; // File-specific methods. - + /** * Open a file at PATH, initializing the native state to operate on * that open file. - * + * * @param path The absolute file path. - * @throws IOException If the file cannot be opened, or if this + * @throws IOException If the file cannot be opened, or if this * channel was previously initialized. */ public void openFile(String path, int mode) throws IOException @@ -530,25 +530,25 @@ public final class VMChannel nfd.setNativeFD(fd); kind = Kind.FILE; } - + private static native int open(String path, int mode) throws IOException; - + public long position() throws IOException { if (kind != Kind.FILE) throw new IOException("not a file"); return position(nfd.getNativeFD()); } - + private static native long position(int fd) throws IOException; - + public void seek(long pos) throws IOException { if (kind != Kind.FILE) throw new IOException("not a file"); seek(nfd.getNativeFD(), pos); } - + private static native void seek(int fd, long pos) throws IOException; public void truncate(long length) throws IOException @@ -557,9 +557,9 @@ public final class VMChannel throw new IOException("not a file"); truncate(nfd.getNativeFD(), length); } - + private static native void truncate(int fd, long len) throws IOException; - + public boolean lock(long pos, long len, boolean shared, boolean wait) throws IOException { @@ -567,27 +567,27 @@ public final class VMChannel throw new IOException("not a file"); return lock(nfd.getNativeFD(), pos, len, shared, wait); } - + private static native boolean lock(int fd, long pos, long len, boolean shared, boolean wait) throws IOException; - + public void unlock(long pos, long len) throws IOException { if (kind != Kind.FILE) throw new IOException("not a file"); unlock(nfd.getNativeFD(), pos, len); } - + private static native void unlock(int fd, long pos, long len) throws IOException; - + public long size() throws IOException { if (kind != Kind.FILE) throw new IOException("not a file"); return size(nfd.getNativeFD()); } - + private static native long size(int fd) throws IOException; public MappedByteBuffer map(char mode, long position, int size) @@ -597,22 +597,22 @@ public final class VMChannel throw new IOException("not a file"); return map(nfd.getNativeFD(), mode, position, size); } - + private static native MappedByteBuffer map(int fd, char mode, long position, int size) throws IOException; - + public boolean flush(boolean metadata) throws IOException { if (kind != Kind.FILE) throw new IOException("not a file"); return flush(nfd.getNativeFD(), metadata); } - + private static native boolean flush(int fd, boolean metadata) throws IOException; - + // Close. - + /** * Close this socket. The socket is also automatically closed when this * object is finalized. @@ -624,13 +624,13 @@ public final class VMChannel { nfd.close(); } - + static native void close(int native_fd) throws IOException; - + /** * <p>Provides a simple mean for the JNI code to find out whether the * current thread was interrupted by a call to Thread.interrupt().</p> - * + * * @return */ static boolean isThreadInterrupted() @@ -639,15 +639,15 @@ public final class VMChannel } // Inner classes. - + /** * A wrapper for a native file descriptor integer. This tracks the state - * of an open file descriptor, and ensures that - * + * of an open file descriptor, and ensures that + * * This class need not be fully supported by virtual machines; if a * virtual machine does not use integer file descriptors, or does and * wishes to hide that, then the methods of this class may be stubbed out. - * + * * System-specific classes that depend on access to native file descriptor * integers SHOULD declare this fact. */ @@ -656,31 +656,31 @@ public final class VMChannel private int native_fd; private boolean valid; private boolean closed; - + State() { native_fd = -1; valid = false; closed = false; } - + public boolean isValid() { return valid; } - + public boolean isClosed() { return closed; } - + public int getNativeFD() throws IOException { if (!valid) throw new IOException("invalid file descriptor"); return native_fd; } - + void setNativeFD(final int native_fd) throws IOException { if (valid) @@ -688,7 +688,7 @@ public final class VMChannel this.native_fd = native_fd; valid = true; } - + public void close() throws IOException { if (!valid) @@ -703,7 +703,7 @@ public final class VMChannel closed = true; } } - + public String toString() { if (closed) @@ -712,7 +712,7 @@ public final class VMChannel return "<<invalid>>"; return String.valueOf(native_fd); } - + protected void finalize() throws Throwable { try @@ -726,7 +726,7 @@ public final class VMChannel } } } - + /** * An enumeration of possible kinds of channel. */ @@ -734,16 +734,16 @@ public final class VMChannel { /** A streaming (TCP) socket. */ static final Kind SOCK_STREAM = new Kind(); - + /** A datagram (UDP) socket. */ static final Kind SOCK_DGRAM = new Kind(); - + /** A file. */ static final Kind FILE = new Kind(); - + /** Something else; not a socket or file. */ static final Kind OTHER = new Kind(); - + private Kind() { } } } diff --git a/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java b/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java index e5257c1cf96..a369704522a 100644 --- a/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java +++ b/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java @@ -57,7 +57,7 @@ final class VMPipe System.loadLibrary ("javanio"); } } - + /** * Create a pipe, consisting of a readable VMChannel and a writable * VMChannel. The readable channel is returned is the first element @@ -75,6 +75,6 @@ final class VMPipe pipe[1] = new VMChannel(fds[1]); return pipe; } - + private static native int[] pipe0() throws IOException; } diff --git a/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java b/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java index 488132d24c2..4d37c2c1ca9 100644 --- a/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java +++ b/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java @@ -1,4 +1,4 @@ -/* VMSelector.java -- +/* VMSelector.java -- Copyright (C) 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -50,7 +50,7 @@ public final class VMSelector System.loadLibrary ("javanio"); } } - + // A timeout value of 0 means block forever. static native int select (int[] read, int[] write, int[] except, long timeout) diff --git a/libjava/classpath/vm/reference/gnu/java/security/jce/prng/VMSecureRandom.java b/libjava/classpath/vm/reference/gnu/java/security/jce/prng/VMSecureRandom.java index 28a02102706..86faa097c17 100644 --- a/libjava/classpath/vm/reference/gnu/java/security/jce/prng/VMSecureRandom.java +++ b/libjava/classpath/vm/reference/gnu/java/security/jce/prng/VMSecureRandom.java @@ -126,4 +126,4 @@ final class VMSecureRandom running = false; } } -}
\ No newline at end of file +} |