diff options
Diffstat (limited to 'libjava/classpath/vm/reference')
40 files changed, 307 insertions, 167 deletions
diff --git a/libjava/classpath/vm/reference/gnu/classpath/VMStackWalker.java b/libjava/classpath/vm/reference/gnu/classpath/VMStackWalker.java index 2214e757110..26c4053565b 100644 --- a/libjava/classpath/vm/reference/gnu/classpath/VMStackWalker.java +++ b/libjava/classpath/vm/reference/gnu/classpath/VMStackWalker.java @@ -1,5 +1,5 @@ /* VMStackWalker.java -- Reference implementation of VM hooks for stack access - Copyright (C) 2005, 2006 Free Software Foundation + Copyright (C) 2005, 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -51,6 +51,9 @@ package gnu.classpath; */ public final class VMStackWalker { + + private VMStackWalker() {} // Prohibits instantiation. + /** * Get a list of all the classes currently executing methods on the * Java stack. <code>getClassContext()[0]</code> is the class associated diff --git a/libjava/classpath/vm/reference/gnu/classpath/VMSystemProperties.java b/libjava/classpath/vm/reference/gnu/classpath/VMSystemProperties.java index 1e0dd4e2632..d1ce7751c24 100644 --- a/libjava/classpath/vm/reference/gnu/classpath/VMSystemProperties.java +++ b/libjava/classpath/vm/reference/gnu/classpath/VMSystemProperties.java @@ -1,5 +1,5 @@ /* VMSystemProperties.java -- Allow the VM to set System properties. - Copyright (C) 2004 Free Software Foundation + Copyright (C) 2004, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,8 +39,11 @@ package gnu.classpath; import java.util.Properties; -class VMSystemProperties +final class VMSystemProperties { + + private VMSystemProperties() {} // Prohibits instantiation. + /** * Get the system properties. This is done here, instead of in System, * because of the bootstrap sequence. Note that the native code should diff --git a/libjava/classpath/vm/reference/gnu/java/lang/VMCPStringBuilder.java b/libjava/classpath/vm/reference/gnu/java/lang/VMCPStringBuilder.java index c3a3784f398..391f7af953d 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/VMCPStringBuilder.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/VMCPStringBuilder.java @@ -1,5 +1,5 @@ /* VMCPStringBuilder.java -- Growable strings without locking or copying - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -72,6 +72,8 @@ final class VMCPStringBuilder } } + private VMCPStringBuilder() {} // Prohibits instantiation. + /** * Convert this <code>StringBuilder</code> to a <code>String</code>. The * String is composed of the characters currently in this StringBuilder. Note diff --git a/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java index 5501f0f7f5b..d9583ac8cce 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/VMInstrumentationImpl.java @@ -1,6 +1,6 @@ /* VMInstrumentationImpl.java -- interface for the GNU implementation of InstrumentationImpl - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,6 +49,8 @@ import java.lang.instrument.Instrumentation; final class VMInstrumentationImpl { + private VMInstrumentationImpl() {} // Prohibits instantiation. + /** * Returns if the current JVM supports class redefinition * 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 ea49897419b..7b94020a46a 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java @@ -1,5 +1,5 @@ /* VMClassLoadingMXBeanImpl.java - VM impl. of a class loading bean - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,6 +49,8 @@ package gnu.java.lang.management; final class VMClassLoadingMXBeanImpl { + private VMClassLoadingMXBeanImpl() {} // Prohibits instantiation. + /** * Returns the number of classes currently loaded by * the virtual machine. 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 019af0ca411..f421a8aa49f 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java @@ -1,5 +1,5 @@ /* VMCompilationMXBeanImpl.java - VM implementation of a compilation bean - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -50,6 +50,8 @@ package gnu.java.lang.management; final class VMCompilationMXBeanImpl { + private VMCompilationMXBeanImpl() {} // Prohibits instantiation. + /** * Returns the number of milliseconds the JIT * compiler has spent compiling Java bytecode 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 00861bc21de..99450b4107d 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java @@ -1,5 +1,5 @@ /* VMGarbageCollectorMXBeanImpl.java - VM interface for a GC bean - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -52,6 +52,8 @@ package gnu.java.lang.management; final class VMGarbageCollectorMXBeanImpl { + private VMGarbageCollectorMXBeanImpl() {} // Prohibits instantiation. + /** * Returns the number of collections the garbage collector * represented by this bean has made. -1 is returned if the 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 7f69bdfb741..12aa886186e 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java @@ -1,5 +1,5 @@ /* VMMemoryMXBeanImpl.java - VM impl. of a memory bean - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -57,6 +57,8 @@ import java.util.List; final class VMMemoryMXBeanImpl { + private VMMemoryMXBeanImpl() {} // Prohibits instantiation. + /** * Returns an instance of {@link java.lang.management.MemoryUsage} * with appropriate initial, used, committed and maximum values 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 477329f0aed..81a8c0d216a 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java @@ -1,5 +1,5 @@ /* VMMemoryManagerMXBeanImpl.java - VM interface for a memory manager bean - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -56,6 +56,8 @@ import java.util.List; final class VMMemoryManagerMXBeanImpl { + private VMMemoryManagerMXBeanImpl() {} // Prohibits instantiation. + /** * Returns an array containing the names of the memory pools * this memory manager manages. 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 36cd2586a8e..39775c4edae 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java @@ -1,5 +1,5 @@ /* MemoryPoolMXBeanImpl.java - VM interface for memory pool beans - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,6 +49,8 @@ import java.lang.management.MemoryUsage; final class VMMemoryPoolMXBeanImpl { + private VMMemoryPoolMXBeanImpl() {} // Prohibits instantiation. + /** * Returns memory usage statistics for the specified pool * just after a best-effort attempt to free memory. This diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMOperatingSystemMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMOperatingSystemMXBeanImpl.java index 20b3f9ed271..5530007aeb1 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMOperatingSystemMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMOperatingSystemMXBeanImpl.java @@ -1,5 +1,5 @@ /* VMOperatingSystemMXBeanImpl.java - VM implementation of an OS bean - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -56,6 +56,8 @@ final class VMOperatingSystemMXBeanImpl } } + private VMOperatingSystemMXBeanImpl() {} // Prohibits instantiation. + /** * Returns the system load average from the last * minute. diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java index 32a86604614..1bffa75c50d 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java @@ -1,5 +1,5 @@ /* VMRuntimeMXBeanImpl.java - VM implementation of an runtime bean - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,6 +48,8 @@ import gnu.classpath.SystemProperties; final class VMRuntimeMXBeanImpl { + private VMRuntimeMXBeanImpl() {} // Prohibits instantiation. + /** * Returns the command-line arguments supplied * to the virtual machine, excluding those supplied 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 33448d9d534..8fd0d90a281 100644 --- a/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java @@ -1,5 +1,5 @@ /* VMThreadMXBeanImpl.java - VM impl. of a thread bean - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -58,6 +58,8 @@ final class VMThreadMXBeanImpl */ private static int filled; + private VMThreadMXBeanImpl() {} // Prohibits instantiation. + /** * Returns the ids of cycles of deadlocked threads, occurring * due to monitor ownership or ownable synchronizer ownership. diff --git a/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java b/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java index da0f893cfbc..399470036d2 100644 --- a/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java +++ b/libjava/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java @@ -1,5 +1,5 @@ /* PlainDatagramSocketImpl.java -- VM interface for DatagramSocket impl - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,7 +53,7 @@ import java.net.SocketException; * @author Ingo Proetel (proetel@aicas.com) * @author Roman Kennke (kennke@aicas.com) */ -public final class VMPlainDatagramSocketImpl +final class VMPlainDatagramSocketImpl { /** * Option id for the IP_TTL (time to live) value. @@ -70,8 +70,10 @@ public final class VMPlainDatagramSocketImpl } } + private VMPlainDatagramSocketImpl() {} // Prohibits instantiation. + /** - * Binds this socket to a particular port and interface + * Binds this socket to a particular port and interface. * * @param socket the socket object * @param port the port to bind to diff --git a/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java b/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java index a369704522a..9a075342572 100644 --- a/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java +++ b/libjava/classpath/vm/reference/gnu/java/nio/VMPipe.java @@ -1,5 +1,5 @@ /* VMPipe.java -- Reference implementation for VM hooks used by PipeImpl - Copyright (C) 2004 Free Software Foundation + Copyright (C) 2004, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -58,6 +58,8 @@ final class VMPipe } } + private VMPipe() {} // Prohibits instantiation. + /** * Create a pipe, consisting of a readable VMChannel and a writable * VMChannel. The readable channel is returned is the first element diff --git a/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java b/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java index 4d37c2c1ca9..18fad5c8a62 100644 --- a/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java +++ b/libjava/classpath/vm/reference/gnu/java/nio/VMSelector.java @@ -1,5 +1,5 @@ /* VMSelector.java -- - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,8 +40,9 @@ package gnu.java.nio; import gnu.classpath.Configuration; import java.io.IOException; -public final class VMSelector +final class VMSelector { + static { // load the shared library needed for native methods. @@ -51,6 +52,8 @@ public final class VMSelector } } + private VMSelector() {} // Prohibits instantiation. + // 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 86faa097c17..fef92d8457f 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 @@ -1,5 +1,5 @@ /* VMSecureRandom.java -- random seed generator. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -55,6 +55,8 @@ package gnu.java.security.jce.prng; final class VMSecureRandom { + private VMSecureRandom() {} // Prohibits instantiation. + /** * Generate a random seed. Implementations are free to generate * fewer random bytes than are requested, and leave the remaining @@ -104,7 +106,8 @@ final class VMSecureRandom return length; } - static class Spinner implements Runnable + static class Spinner + implements Runnable { volatile byte value; volatile boolean running; @@ -121,7 +124,7 @@ final class VMSecureRandom value++; } - private void stop() + void stop() { running = false; } diff --git a/libjava/classpath/vm/reference/java/io/VMConsole.java b/libjava/classpath/vm/reference/java/io/VMConsole.java new file mode 100644 index 00000000000..69c9df9527f --- /dev/null +++ b/libjava/classpath/vm/reference/java/io/VMConsole.java @@ -0,0 +1,44 @@ +/* VMConsole.java -- helper for java.io.Console + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +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 +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.io; + +public final class VMConsole +{ + static native String readPassword(Console con); +} diff --git a/libjava/classpath/vm/reference/java/io/VMFile.java b/libjava/classpath/vm/reference/java/io/VMFile.java index 2af1e95c864..f2ac5c38c93 100644 --- a/libjava/classpath/vm/reference/java/io/VMFile.java +++ b/libjava/classpath/vm/reference/java/io/VMFile.java @@ -1,5 +1,5 @@ /* VMFile.java -- Class for methods natively accessing files - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -50,6 +50,7 @@ import gnu.java.io.PlatformHelper; */ final class VMFile { + // FIXME: We support only case sensitive filesystems currently. static final boolean IS_CASE_SENSITIVE = true; static final boolean IS_DOS_8_3 = false; @@ -62,105 +63,113 @@ final class VMFile } } - /* + private VMFile() {} // Prohibits instantiation. + + /** * This native method does the actual work of getting the last file * modification time. It also does the existence check to avoid the - * overhead of a call to exists() + * overhead of a call to exists(). */ static native long lastModified(String path); - /* + /** * This native method sets the permissions to make the file read only. + * + * @return true if file exists and the operation completed successfully */ static native boolean setReadOnly(String path); /** - * This method is used to create a temporary file + * This method is used to create a temporary file. */ static native boolean create(String path) throws IOException; - /* + /** * This native function actually produces the list of files in this - * directory + * directory. + * + * @return null if dirpath does not exist or is not a directory; + * null or empty array if the directory is unreadable; an array of + * file names in the directory otherwise. */ static native synchronized String[] list(String dirpath); - /* + /** * This native method actually performs the rename. */ static native boolean renameTo(String targetpath, String destpath); - /* + /** * This native method actually determines the length of the file and - * handles the existence check + * handles the existence check. */ static native long length(String path); - /* + /** * This native method does the actual checking of file existence. */ static native boolean exists(String path); - /* - * This native method handles the actual deleting of the file + /** + * This native method handles the actual deleting of the file. */ static native boolean delete(String path); - /* + /** * This method does the actual setting of the modification time. */ static native boolean setLastModified(String path, long time); - /* - * This native method actually creates the directory + /** + * This native method actually creates the directory. */ static native boolean mkdir(String dirpath); /** * Gets the total bytes of the filesystem named by path. */ - public static native long getTotalSpace(String path); + static native long getTotalSpace(String path); /** * Gets the total free bytes of the filesystem named by path. */ - public static native long getFreeSpace(String path); + static native long getFreeSpace(String path); /** * Gets the available bytes of the filesystem named by path. */ - public static native long getUsableSpace(String path); + static native long getUsableSpace(String path); /** * Set the read permission of the file. */ - public static synchronized native boolean setReadable(String path, - boolean readable, - boolean ownerOnly); + static synchronized native boolean setReadable(String path, + boolean readable, + boolean ownerOnly); /** * Set the write permission of the file. */ - public static synchronized native boolean setWritable(String path, - boolean writable, - boolean ownerOnly); + static synchronized native boolean setWritable(String path, + boolean writable, + boolean ownerOnly); /** * Set the execute permission of the file. */ - public static synchronized native boolean setExecutable(String path, - boolean executable, - boolean ownerOnly); + static synchronized native boolean setExecutable(String path, + boolean executable, + boolean ownerOnly); - /* + /** * This native method does the actual check of whether or not a file * is a plain file or not. It also handles the existence check to - * eliminate the overhead of a call to exists() + * eliminate the overhead of a call to exists(). */ static native boolean isFile(String path); /** - * This native method checks file permissions for writing + * This native method checks file permissions for writing. */ static synchronized native boolean canWrite(String path); @@ -170,19 +179,23 @@ final class VMFile static native boolean canWriteDirectory(String path); /** - * This native method checks file permissions for reading + * This native method checks file permissions for reading. + * It also handles the existence check to eliminate the overhead of + * a call to exists(). */ static synchronized native boolean canRead(String path); /** - * This native method checks file permissions for execution + * This native method checks file permissions for execution. + * It also handles the existence check to eliminate the overhead of + * a call to exists(). */ static synchronized native boolean canExecute(String path); - /* + /** * This method does the actual check of whether or not a file is a - * directory or not. It also handle the existence check to eliminate - * the overhead of a call to exists() + * directory or not. It also handles the existence check to eliminate + * the overhead of a call to exists(). */ static native boolean isDirectory(String dirpath); @@ -359,9 +372,9 @@ final class VMFile * <p> * Note that this method, unlike the other methods which return path * names, can throw an IOException. This is because native method - * might be required in order to resolve the canonical path + * might be required in order to resolve the canonical path. * * @exception IOException If an error occurs */ - public static native String toCanonicalForm(String path) throws IOException; + static native String toCanonicalForm(String path) throws IOException; } diff --git a/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java b/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java index 10e1f34cbd2..a29115bbe39 100644 --- a/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java +++ b/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java @@ -1,5 +1,5 @@ /* ObjectInputStream.java -- Class used to read serialized objects - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,6 +44,7 @@ import java.lang.reflect.Constructor; final class VMObjectInputStream { + static { if (Configuration.INIT_LOAD_LIBRARY) @@ -52,6 +53,8 @@ final class VMObjectInputStream } } + private VMObjectInputStream() {} // Prohibits instantiation. + /** * Allocates a new Object of type clazz but without running the * default constructor on it. It then calls the given constructor on diff --git a/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java b/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java index fbaf7d6c8c5..6a78d8ec898 100644 --- a/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java +++ b/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java @@ -1,5 +1,5 @@ /* VMObjectStreamClass.java -- VM helper functions for ObjectStreamClass - Copyright (C) 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2005, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,6 +43,7 @@ import java.lang.reflect.Field; final class VMObjectStreamClass { + static { if (Configuration.INIT_LOAD_LIBRARY) @@ -51,6 +52,8 @@ final class VMObjectStreamClass } } + private VMObjectStreamClass() {} // Prohibits instantiation. + /** * Returns true if CLAZZ has a static class initializer * (a.k.a. <clinit>). diff --git a/libjava/classpath/vm/reference/java/lang/VMClass.java b/libjava/classpath/vm/reference/java/lang/VMClass.java index a0091c073c5..d80eecdfd9a 100644 --- a/libjava/classpath/vm/reference/java/lang/VMClass.java +++ b/libjava/classpath/vm/reference/java/lang/VMClass.java @@ -303,20 +303,21 @@ final class VMClass return getComponentType(klass).getSimpleName() + "[]"; } String fullName = getName(klass); - int pos = fullName.lastIndexOf("$"); - if (pos == -1) - pos = 0; - else - { - ++pos; - while (Character.isDigit(fullName.charAt(pos))) - ++pos; - } - int packagePos = fullName.lastIndexOf(".", pos); - if (packagePos == -1) - return fullName.substring(pos); - else - return fullName.substring(packagePos + 1); + Class enclosingClass = getEnclosingClass(klass); + if (enclosingClass == null) + // It's a top level class. + return fullName.substring(fullName.lastIndexOf(".") + 1); + + fullName = fullName.substring(enclosingClass.getName().length()); + + // We've carved off the enclosing class name; now we must have '$' + // followed optionally by digits, followed by the class name. + int pos = 1; + while (Character.isDigit(fullName.charAt(pos))) + ++pos; + fullName = fullName.substring(pos); + + return fullName; } /** diff --git a/libjava/classpath/vm/reference/java/lang/VMClassLoader.java b/libjava/classpath/vm/reference/java/lang/VMClassLoader.java index c1d4625883c..bab7c23cc67 100644 --- a/libjava/classpath/vm/reference/java/lang/VMClassLoader.java +++ b/libjava/classpath/vm/reference/java/lang/VMClassLoader.java @@ -1,6 +1,7 @@ /* VMClassLoader.java -- Reference implementation of native interface required by ClassLoader - Copyright (C) 1998, 2001, 2002, 2004, 2005, 2006 Free Software Foundation + Copyright (C) 1998, 2001, 2002, 2004, 2005, 2006, 2010 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -71,7 +72,6 @@ import java.util.zip.ZipFile; final class VMClassLoader { - /** packages loaded by the bootstrap class loader */ static final HashMap definedPackages = new HashMap(); @@ -116,6 +116,7 @@ final class VMClassLoader } } + private VMClassLoader() {} // Prohibits instantiation. /** * Helper to define a class using a string of bytes. This assumes that @@ -172,6 +173,7 @@ final class VMClassLoader return (URL)e.nextElement(); return null; } + /** * Helper to get a list of resources from the bootstrap class loader. * @@ -239,7 +241,6 @@ final class VMClassLoader return v.elements(); } - /** * Returns a String[] of native package names. The default * implementation tries to load a list of package from @@ -284,7 +285,6 @@ final class VMClassLoader return new String[0]; } - /** * Helper to get a package from the bootstrap class loader. * diff --git a/libjava/classpath/vm/reference/java/lang/VMCompiler.java b/libjava/classpath/vm/reference/java/lang/VMCompiler.java index fe740075671..9a7d83facee 100644 --- a/libjava/classpath/vm/reference/java/lang/VMCompiler.java +++ b/libjava/classpath/vm/reference/java/lang/VMCompiler.java @@ -1,5 +1,5 @@ /* VMClassLoader.java -- Reference implementation of compiler interface - Copyright (C) 2004 Free Software Foundation + Copyright (C) 2004, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -58,7 +58,7 @@ final class VMCompiler * compilation failed, <code>true</code> if compilation succeeded * @throws NullPointerException if oneClass is null */ - public static boolean compileClass(Class oneClass) + static boolean compileClass(Class oneClass) { // Never succeed. return false; @@ -72,7 +72,7 @@ final class VMCompiler * compilation failed, <code>true</code> if compilation succeeded * @throws NullPointerException if classNames is null */ - public static boolean compileClasses(String classNames) + static boolean compileClasses(String classNames) { // Note the incredibly lame interface. Always fail. return false; @@ -87,7 +87,7 @@ final class VMCompiler * @return a compiler-specific value, including null * @throws NullPointerException if the compiler doesn't like a null arg */ - public static Object command(Object arg) + static Object command(Object arg) { // Our implementation defines this to a no-op. return null; @@ -98,7 +98,7 @@ final class VMCompiler * to resume operation if it was previously disabled; provided that a * compiler even exists. */ - public static void enable() + static void enable() { } @@ -106,7 +106,7 @@ final class VMCompiler * Calling <code>Compiler.disable()</code> will cause the compiler * to be suspended; provided that a compiler even exists. */ - public static void disable() + static void disable() { } } diff --git a/libjava/classpath/vm/reference/java/lang/VMDouble.java b/libjava/classpath/vm/reference/java/lang/VMDouble.java index 8e523cd2e85..edfa723a052 100644 --- a/libjava/classpath/vm/reference/java/lang/VMDouble.java +++ b/libjava/classpath/vm/reference/java/lang/VMDouble.java @@ -1,5 +1,5 @@ /* VMDouble.java -- VM Specific Double methods - Copyright (C) 2003, 2005 Free Software Foundation + Copyright (C) 2003, 2005, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -65,6 +65,8 @@ final class VMDouble initIDs(); } + private VMDouble() {} // Prohibits instantiation. + /** * Convert the double to the IEEE 754 floating-point "double format" bit * layout. Bit 63 (the most significant) is the sign bit, bits 62-52 @@ -79,7 +81,7 @@ final class VMDouble * @return the bits of the <code>double</code> * @see #longBitsToDouble(long) */ - public static native long doubleToRawLongBits(double value); + static native long doubleToRawLongBits(double value); /** * Convert the argument in IEEE 754 floating-point "double format" bit @@ -94,7 +96,7 @@ final class VMDouble * @see #doubleToLongBits(double) * @see #doubleToRawLongBits(double) */ - public static native double longBitsToDouble(long bits); + static native double longBitsToDouble(long bits); /** * Helper method to convert to string. @@ -103,13 +105,18 @@ final class VMDouble * @param isFloat true if the conversion is requested by Float (results in * fewer digits) */ - public static native String toString(double d, boolean isFloat); + static native String toString(double d, boolean isFloat); /** * Initialize JNI cache. This method is called only by the * static initializer when using JNI. */ - public static native void initIDs(); + private static native void initIDs(); - public static native double parseDouble(String str); + /** + * Parse the specified String as a double. + * @throws NumberFormatException if str cannot be parsed + * @throws NullPointerException if str is null + */ + static native double parseDouble(String str); } diff --git a/libjava/classpath/vm/reference/java/lang/VMFloat.java b/libjava/classpath/vm/reference/java/lang/VMFloat.java index ba523d6973e..e6e784f3392 100644 --- a/libjava/classpath/vm/reference/java/lang/VMFloat.java +++ b/libjava/classpath/vm/reference/java/lang/VMFloat.java @@ -1,5 +1,5 @@ /* VMFloat.java -- VM Specific Float methods - Copyright (C) 2003 Free Software Foundation + Copyright (C) 2003, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -63,6 +63,8 @@ final class VMFloat } } + private VMFloat() {} // Prohibits instantiation. + /** * Convert the float to the IEEE 754 floating-point "single format" bit * layout. Bit 31 (the most significant) is the sign bit, bits 30-23 diff --git a/libjava/classpath/vm/reference/java/lang/VMMath.java b/libjava/classpath/vm/reference/java/lang/VMMath.java index dc5fd420708..35c3f645e42 100644 --- a/libjava/classpath/vm/reference/java/lang/VMMath.java +++ b/libjava/classpath/vm/reference/java/lang/VMMath.java @@ -1,5 +1,5 @@ /* VMMath.java -- Common mathematical functions. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,7 +40,7 @@ package java.lang; import gnu.classpath.Configuration; -class VMMath +final class VMMath { static @@ -51,6 +51,8 @@ class VMMath } } + private VMMath() {} // Prohibits instantiation. + /** * The trigonometric function <em>sin</em>. The sine of NaN or infinity is * NaN, and the sine of 0 retains its sign. This is accurate within 1 ulp, @@ -59,7 +61,7 @@ class VMMath * @param a the angle (in radians) * @return sin(a) */ - public static native double sin(double a); + static native double sin(double a); /** * The trigonometric function <em>cos</em>. The cosine of NaN or infinity is @@ -68,7 +70,7 @@ class VMMath * @param a the angle (in radians) * @return cos(a) */ - public static native double cos(double a); + static native double cos(double a); /** * The trigonometric function <em>tan</em>. The tangent of NaN or infinity @@ -78,7 +80,7 @@ class VMMath * @param a the angle (in radians) * @return tan(a) */ - public static native double tan(double a); + static native double tan(double a); /** * The trigonometric function <em>arcsin</em>. The range of angles returned @@ -89,7 +91,7 @@ class VMMath * @param a the sin to turn back into an angle * @return arcsin(a) */ - public static native double asin(double a); + static native double asin(double a); /** * The trigonometric function <em>arccos</em>. The range of angles returned @@ -100,7 +102,7 @@ class VMMath * @param a the cos to turn back into an angle * @return arccos(a) */ - public static native double acos(double a); + static native double acos(double a); /** * The trigonometric function <em>arcsin</em>. The range of angles returned @@ -112,7 +114,7 @@ class VMMath * @return arcsin(a) * @see #atan2(double, double) */ - public static native double atan(double a); + static native double atan(double a); /** * A special version of the trigonometric function <em>arctan</em>, for @@ -161,7 +163,7 @@ class VMMath * @return <em>theta</em> in the conversion of (x, y) to (r, theta) * @see #atan(double) */ - public static native double atan2(double y, double x); + static native double atan2(double y, double x); /** * Take <em>e</em><sup>a</sup>. The opposite of <code>log()</code>. If the @@ -175,7 +177,7 @@ class VMMath * @see #log(double) * @see #pow(double, double) */ - public static native double exp(double a); + static native double exp(double a); /** * Take ln(a) (the natural log). The opposite of <code>exp()</code>. If the @@ -191,7 +193,7 @@ class VMMath * @return the natural log of <code>a</code> * @see #exp(double) */ - public static native double log(double a); + static native double log(double a); /** * Take a square root. If the argument is NaN or negative, the result is @@ -205,7 +207,7 @@ class VMMath * @return the square root of the argument * @see #pow(double, double) */ - public static native double sqrt(double a); + static native double sqrt(double a); /** * Raise a number to a power. Special cases:<ul> @@ -275,7 +277,7 @@ class VMMath * @param b the power to raise it to * @return a<sup>b</sup> */ - public static native double pow(double a, double b); + static native double pow(double a, double b); /** * Get the IEEE 754 floating point remainder on two numbers. This is the @@ -291,7 +293,7 @@ class VMMath * @return the IEEE 754-defined floating point remainder of x/y * @see #rint(double) */ - public static native double IEEEremainder(double x, double y); + static native double IEEEremainder(double x, double y); /** * Take the nearest integer that is that is greater than or equal to the @@ -302,7 +304,7 @@ class VMMath * @param a the value to act upon * @return the nearest integer >= <code>a</code> */ - public static native double ceil(double a); + static native double ceil(double a); /** * Take the nearest integer that is that is less than or equal to the @@ -312,7 +314,7 @@ class VMMath * @param a the value to act upon * @return the nearest integer <= <code>a</code> */ - public static native double floor(double a); + static native double floor(double a); /** * Take the nearest integer to the argument. If it is exactly between @@ -322,7 +324,7 @@ class VMMath * @param a the value to act upon * @return the nearest integer to <code>a</code> */ - public static native double rint(double a); + static native double rint(double a); /** * <p> @@ -342,7 +344,7 @@ class VMMath * @see #sqrt(double) * @see #pow(double, double) */ - public static native double cbrt(double a); + static native double cbrt(double a); /** * <p> @@ -362,7 +364,7 @@ class VMMath * @return the hyperbolic cosine of <code>a</code>. * @since 1.5 */ - public static native double cosh(double a); + static native double cosh(double a); /** * <p> @@ -382,7 +384,7 @@ class VMMath * @return <code>e<sup>a</sup> - 1</code> * @since 1.5 */ - public static native double expm1(double a); + static native double expm1(double a); /** * <p> @@ -402,7 +404,7 @@ class VMMath * @return the hypotenuse matching the supplied parameters. * @since 1.5 */ - public static native double hypot(double a, double b); + static native double hypot(double a, double b); /** * <p> @@ -422,7 +424,7 @@ class VMMath * @return the base 10 logarithm of <code>a</code>. * @since 1.5 */ - public static native double log10(double a); + static native double log10(double a); /** * <p> @@ -444,7 +446,7 @@ class VMMath * @return the natural logarithm of <code>a</code> + 1. * @since 1.5 */ - public static native double log1p(double a); + static native double log1p(double a); /** * <p> @@ -463,7 +465,7 @@ class VMMath * @return the hyperbolic sine of <code>a</code>. * @since 1.5 */ - public static native double sinh(double a); + static native double sinh(double a); /** * <p> @@ -488,6 +490,5 @@ class VMMath * @return the hyperbolic tangent of <code>a</code>. * @since 1.5 */ - public static native double tanh(double a); - + static native double tanh(double a); } diff --git a/libjava/classpath/vm/reference/java/lang/VMObject.java b/libjava/classpath/vm/reference/java/lang/VMObject.java index 279f250c089..6a0785330bd 100644 --- a/libjava/classpath/vm/reference/java/lang/VMObject.java +++ b/libjava/classpath/vm/reference/java/lang/VMObject.java @@ -1,5 +1,5 @@ /* VMObject.java -- Reference implementation for VM hooks used by Object - Copyright (C) 1998, 2002, 2005 Free Software Foundation + Copyright (C) 1998, 2002, 2005, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,6 +46,9 @@ package java.lang; */ final class VMObject { + + private VMObject() {} // Prohibits instantiation. + /** * Returns the runtime {@link Class} of a given Object. * diff --git a/libjava/classpath/vm/reference/java/lang/VMString.java b/libjava/classpath/vm/reference/java/lang/VMString.java index e1fbf839023..181e08543f5 100644 --- a/libjava/classpath/vm/reference/java/lang/VMString.java +++ b/libjava/classpath/vm/reference/java/lang/VMString.java @@ -1,5 +1,5 @@ /* VMString.java -- VM Specific String methods - Copyright (C) 2003 Free Software Foundation + Copyright (C) 2003, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -60,6 +60,8 @@ final class VMString */ private static final WeakHashMap internTable = new WeakHashMap(); + private VMString() {} // Prohibits instantiation. + /** * Fetches this String from the intern hashtable. If two Strings are * considered equal, by the equals() method, then intern() will return the diff --git a/libjava/classpath/vm/reference/java/lang/VMSystem.java b/libjava/classpath/vm/reference/java/lang/VMSystem.java index 52a3c1c9f66..0b3d6920055 100644 --- a/libjava/classpath/vm/reference/java/lang/VMSystem.java +++ b/libjava/classpath/vm/reference/java/lang/VMSystem.java @@ -1,5 +1,5 @@ /* VMSystem.java -- helper for java.lang.system - Copyright (C) 1998, 2002, 2004 Free Software Foundation + Copyright (C) 1998, 2002, 2004, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -56,6 +56,9 @@ import java.io.PrintStream; */ final class VMSystem { + + private VMSystem() {} // Prohibits instantiation. + /** * Copy one array onto another from <code>src[srcStart]</code> ... * <code>src[srcStart+len-1]</code> to <code>dest[destStart]</code> ... @@ -95,15 +98,6 @@ final class VMSystem static native int identityHashCode(Object o); /** - * Convert a library name to its platform-specific variant. - * - * @param libname the library name, as used in <code>loadLibrary</code> - * @return the platform-specific mangling of the name - * @XXX Add this method - static native String mapLibraryName(String libname); - */ - - /** * Set {@link System#in} to a new InputStream. * * @param in the new InputStream @@ -135,10 +129,7 @@ final class VMSystem * @return the current time * @see java.util.Date */ - public static long currentTimeMillis() - { - return nanoTime() / 1000000L; - } + static native long currentTimeMillis(); /** * <p> @@ -165,7 +156,7 @@ final class VMSystem * @return the time of a system timer in nanoseconds. * @since 1.5 */ - public static native long nanoTime(); + static native long nanoTime(); /** * Returns a list of 'name=value' pairs representing the current environment diff --git a/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java b/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java index f10497014b4..253311cdf2c 100644 --- a/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java +++ b/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java @@ -1,5 +1,5 @@ /* VMManagementFactory.java - VM interface for obtaining system beans. - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,6 +48,8 @@ package java.lang.management; final class VMManagementFactory { + private VMManagementFactory() {} // Prohibits instantiation. + /** * Return a list of the names of the currently available * memory pools within the virtual machine. diff --git a/libjava/classpath/vm/reference/java/lang/reflect/VMArray.java b/libjava/classpath/vm/reference/java/lang/reflect/VMArray.java index d6277aebdbd..2055c170eca 100644 --- a/libjava/classpath/vm/reference/java/lang/reflect/VMArray.java +++ b/libjava/classpath/vm/reference/java/lang/reflect/VMArray.java @@ -1,5 +1,6 @@ /* java.lang.reflect.VMArray - VM class for array manipulation by reflection. - Copyright (C) 1998, 1999, 2001, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2001, 2003, 2005, 2010 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,7 +41,7 @@ package java.lang.reflect; import gnu.classpath.Configuration; -class VMArray +final class VMArray { static @@ -51,6 +52,8 @@ class VMArray } } + private VMArray() {} // Prohibits instantiation. + /** * Dynamically create an array of objects. * diff --git a/libjava/classpath/vm/reference/java/lang/reflect/VMProxy.java b/libjava/classpath/vm/reference/java/lang/reflect/VMProxy.java index 8c7b67a7202..a9d6093ebab 100644 --- a/libjava/classpath/vm/reference/java/lang/reflect/VMProxy.java +++ b/libjava/classpath/vm/reference/java/lang/reflect/VMProxy.java @@ -1,5 +1,5 @@ /* VMProxy.java -- VM interface for proxy class - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -67,6 +67,8 @@ final class VMProxy */ static boolean HAVE_NATIVE_GENERATE_PROXY_CLASS = false; + private VMProxy() {} // Prohibits instantiation. + /** * Optional native method to replace (and speed up) the pure Java * implementation of getProxyClass. Only needed if diff --git a/libjava/classpath/vm/reference/java/net/VMInetAddress.java b/libjava/classpath/vm/reference/java/net/VMInetAddress.java index a99c216b96c..97ae09a743a 100644 --- a/libjava/classpath/vm/reference/java/net/VMInetAddress.java +++ b/libjava/classpath/vm/reference/java/net/VMInetAddress.java @@ -1,5 +1,5 @@ /* VMInetAddress.java -- Class to model an Internet address - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,16 +40,17 @@ package java.net; import gnu.classpath.Configuration; -import java.io.Serializable; - -class VMInetAddress implements Serializable +final class VMInetAddress { + static { if (Configuration.INIT_LOAD_LIBRARY) System.loadLibrary("javanet"); } + private VMInetAddress() {} // Prohibits instantiation. + /** * This method looks up the hostname of the local machine * we are on. If the actual hostname cannot be determined, then the @@ -58,12 +59,12 @@ class VMInetAddress implements Serializable * * @return The local hostname. */ - public static native String getLocalHostname(); + static native String getLocalHostname(); /** * Returns the value of the special address INADDR_ANY */ - public static native byte[] lookupInaddrAny() throws UnknownHostException; + static native byte[] lookupInaddrAny() throws UnknownHostException; /** * This method returns the hostname for a given IP address. It will @@ -75,14 +76,14 @@ class VMInetAddress implements Serializable * * @exception UnknownHostException If the reverse lookup fails */ - public static native String getHostByAddr(byte[] ip) + static native String getHostByAddr(byte[] ip) throws UnknownHostException; /** * Returns a list of all IP addresses for a given hostname. Will throw * an UnknownHostException if the hostname cannot be resolved. */ - public static native byte[][] getHostByName(String hostname) + static native byte[][] getHostByName(String hostname) throws UnknownHostException; /** @@ -93,5 +94,5 @@ class VMInetAddress implements Serializable * * @return The IP address as a byte array */ - public static native byte[] aton(String address); + static native byte[] aton(String address); } diff --git a/libjava/classpath/vm/reference/java/net/VMURLConnection.java b/libjava/classpath/vm/reference/java/net/VMURLConnection.java index 19bf5814e67..ae04bdb6a05 100644 --- a/libjava/classpath/vm/reference/java/net/VMURLConnection.java +++ b/libjava/classpath/vm/reference/java/net/VMURLConnection.java @@ -1,5 +1,5 @@ /* VMURLConnection - VM code for URLConnection - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,7 +45,8 @@ import java.io.InputStream; final class VMURLConnection { - public static final int LENGTH = 1024; + + static final int LENGTH = 1024; static { @@ -54,6 +55,8 @@ final class VMURLConnection init(); } + private VMURLConnection() {} // Prohibits instantiation. + private static native void init(); private static native String guessContentTypeFromBuffer(byte[] b, int valid); diff --git a/libjava/classpath/vm/reference/java/nio/VMDirectByteBuffer.java b/libjava/classpath/vm/reference/java/nio/VMDirectByteBuffer.java index 93a83883a0e..41d44d8eb44 100644 --- a/libjava/classpath/vm/reference/java/nio/VMDirectByteBuffer.java +++ b/libjava/classpath/vm/reference/java/nio/VMDirectByteBuffer.java @@ -1,5 +1,5 @@ /* VMDirectByteBuffer.java -- - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,6 +43,7 @@ import gnu.classpath.Pointer; final class VMDirectByteBuffer { + static { // load the shared library needed for native methods. @@ -52,12 +53,24 @@ final class VMDirectByteBuffer } } - static native Pointer allocate (int capacity); + private VMDirectByteBuffer() {} // Prohibits instantiation. + + static native Pointer allocate(int capacity); + static native void free(Pointer address); + static native byte get(Pointer address, int index); - static native void get(Pointer address, int index, byte[] dst, int offset, int length); + + static native void get(Pointer address, int index, byte[] dst, int offset, + int length); + static native void put(Pointer address, int index, byte value); - static native void put(Pointer address, int index, byte[] src, int offset, int length); + + static native void put(Pointer address, int index, byte[] src, int offset, + int length); + static native Pointer adjustAddress(Pointer address, int offset); - static native void shiftDown(Pointer address, int dst_offset, int src_offset, int count); + + static native void shiftDown(Pointer address, int dst_offset, + int src_offset, int count); } diff --git a/libjava/classpath/vm/reference/java/security/VMAccessController.java b/libjava/classpath/vm/reference/java/security/VMAccessController.java index 9299e6f84cc..6e02f571106 100644 --- a/libjava/classpath/vm/reference/java/security/VMAccessController.java +++ b/libjava/classpath/vm/reference/java/security/VMAccessController.java @@ -71,7 +71,7 @@ final class VMAccessController Permissions permissions = new Permissions(); permissions.add(new AllPermission()); ProtectionDomain[] domain = new ProtectionDomain[] { - new ProtectionDomain(source, permissions) + new ProtectionDomain(source, permissions, null, null) }; DEFAULT_CONTEXT = new AccessControlContext(domain); } @@ -188,12 +188,13 @@ final class VMAccessController { Class clazz = classes[i]; String method = methods[i]; + ClassLoader loader = clazz.getClassLoader(); if (DEBUG) { debug("checking " + clazz + "." + method); // subject to getClassLoader RuntimePermission - debug("loader = " + clazz.getClassLoader()); + debug("loader = " + loader); } // If the previous frame was a call to doPrivileged, then this is @@ -225,7 +226,8 @@ final class VMAccessController // Create a static snapshot of this domain, which may change over time // if the current policy changes. domains.add(new ProtectionDomain(domain.getCodeSource(), - domain.getPermissions())); + domain.getPermissions(), + loader, null)); } if (DEBUG) diff --git a/libjava/classpath/vm/reference/java/security/VMSecureRandom.java b/libjava/classpath/vm/reference/java/security/VMSecureRandom.java index bea15497762..0a438455778 100644 --- a/libjava/classpath/vm/reference/java/security/VMSecureRandom.java +++ b/libjava/classpath/vm/reference/java/security/VMSecureRandom.java @@ -1,5 +1,5 @@ /* VMSecureRandom.java -- random seed generator. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -55,6 +55,8 @@ package java.security; final class VMSecureRandom { + private VMSecureRandom() {} // Prohibits instantiation. + /** * Generate a random seed. Implementations are free to generate * fewer random bytes than are requested, and leave the remaining @@ -104,7 +106,8 @@ final class VMSecureRandom return length; } - static class Spinner implements Runnable + static class Spinner + implements Runnable { volatile byte value; volatile boolean running; @@ -121,7 +124,7 @@ final class VMSecureRandom value++; } - private void stop() + void stop() { running = false; } diff --git a/libjava/classpath/vm/reference/java/util/VMTimeZone.java b/libjava/classpath/vm/reference/java/util/VMTimeZone.java index 11061aa32bf..5724180d719 100644 --- a/libjava/classpath/vm/reference/java/util/VMTimeZone.java +++ b/libjava/classpath/vm/reference/java/util/VMTimeZone.java @@ -1,5 +1,5 @@ /* java.util.VMTimeZone - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -51,6 +51,7 @@ import java.io.*; */ final class VMTimeZone { + static { if (Configuration.INIT_LOAD_LIBRARY) @@ -59,6 +60,8 @@ final class VMTimeZone } } + private VMTimeZone() {} // Prohibits instantiation. + /** * This method returns a time zone id string which is in the form * (standard zone name) or (standard zone name)(GMT offset) or diff --git a/libjava/classpath/vm/reference/sun/misc/Unsafe.java b/libjava/classpath/vm/reference/sun/misc/Unsafe.java index e316bdb8da1..6fad6e4e3ea 100644 --- a/libjava/classpath/vm/reference/sun/misc/Unsafe.java +++ b/libjava/classpath/vm/reference/sun/misc/Unsafe.java @@ -1,5 +1,5 @@ /* Unsafe.java - Unsafe operations needed for concurrency - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,10 +48,10 @@ import java.lang.reflect.Field; * @author Tom Tromey (tromey@redhat.com) * @author Andrew John Hughes (gnu_andrew@member.fsf.org) */ -public class Unsafe +public final class Unsafe { // Singleton class. - private static Unsafe unsafe = new Unsafe(); + private static final Unsafe unsafe = new Unsafe(); /** * Private default constructor to prevent creation of an arbitrary |