Index: scripts/makemake.tcl
===================================================================
--- scripts/makemake.tcl (revision 113842)
+++ scripts/makemake.tcl (working copy)
@@ -345,7 +345,7 @@
scan_packages .
# Files created by the build.
classify_source_file . java/lang/ConcreteProcess.java
-classify_source_file classpath java/util/LocaleData.java
+classify_source_file classpath gnu/java/locale/LocaleData.java
classify_source_file classpath gnu/classpath/Configuration.java
puts "## This file was automatically generated by scripts/makemake.tcl"
Index: gnu/java/lang/VMInstrumentationImpl.java
===================================================================
--- gnu/java/lang/VMInstrumentationImpl.java (revision 0)
+++ gnu/java/lang/VMInstrumentationImpl.java (revision 0)
@@ -0,0 +1,119 @@
+/* VMInstrumentationImpl.java -- interface for the GNU implementation
+ of InstrumentationImpl
+ Copyright (C) 2005 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 gnu.java.lang;
+
+import java.lang.instrument.ClassDefinition;
+import java.lang.instrument.Instrumentation;
+
+/**
+ * @author Nicolas Geoffray (nicolas.geoffray@menlina.com)
+ * @since 1.5
+ */
+final class VMInstrumentationImpl
+{
+
+ /**
+ * Returns if the current JVM supports class redefinition
+ *
+ * @return true if the current JVM supports class redefinition
+ */
+ static boolean isRedefineClassesSupported() { return false; }
+
+ /**
+ * Redefines classes given as parameters. The method has to call
+ * the callTransformers from InstrumentationImpl
+ *
+ * @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 UnsupportedOperationException if the JVM does not support
+ * redefinition or the redefinition made unsupported changes
+ * @throws ClassFormatError if a class file is not valid
+ * @throws NoClassDefFoundError if a class name is not equal to the name
+ * in the class file specified
+ * @throws UnsupportedClassVersionError if the class file version numbers
+ * are unsupported
+ * @throws ClassCircularityError if circularity occured with the new
+ * classes
+ * @throws LinkageError if a linkage error occurs
+ */
+ static 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.
+ */
+ static Class[] getAllLoadedClasses()
+ {
+ return new Class[0];
+ }
+
+ /**
+ * 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.
+ */
+ static Class[] getInitiatedClasses(ClassLoader loader)
+ {
+ return new Class[0];
+ }
+
+
+ /**
+ * Get the size of an object. The object is not null
+ *
+ * @param objectToSize the object
+ * @return the size of the object
+ */
+ static long getObjectSize(Object objectToSize)
+ {
+ return 0;
+ }
+}
Index: gnu/java/net/local/LocalSocketImpl.java
===================================================================
--- gnu/java/net/local/LocalSocketImpl.java (revision 0)
+++ gnu/java/net/local/LocalSocketImpl.java (revision 0)
@@ -0,0 +1,310 @@
+/* LocalSocketImpl.java -- a unix domain client socket implementation.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.java.net.local;
+
+import java.io.FileDescriptor;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import java.net.InetAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketImpl;
+
+final class LocalSocketImpl extends SocketImpl
+{
+
+ // Fields.
+ // -------------------------------------------------------------------------
+
+ private boolean created;
+ private InputStream in;
+ private OutputStream out;
+ private int socket_fd;
+ private LocalSocketAddress local;
+ private LocalSocketAddress remote;
+
+ // Constructor.
+ // -------------------------------------------------------------------------
+
+ LocalSocketImpl ()
+ {
+ this (false);
+ }
+
+ LocalSocketImpl (boolean nocreate)
+ {
+ created = nocreate;
+ socket_fd = -1;
+ fd = new FileDescriptor ();
+ }
+
+ // Instance methods.
+ // -------------------------------------------------------------------------
+
+ public void setOption (int opt, Object value) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support options");
+ }
+
+ public Object getOption (int opt) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support options");
+ }
+
+ protected void create (boolean stream) throws IOException { }
+ protected void listen (int timeout) throws IOException { }
+ protected void accept (LocalSocketImpl socket) throws IOException { }
+ protected int available () throws IOException { return -1; }
+ protected void close () throws IOException { }
+ protected void sendUrgentData (int data) throws IOException { }
+ protected void shutdownInput () throws IOException { }
+ protected void shutdownOutput () throws IOException { }
+
+ void unlink () throws IOException { }
+ void localBind (LocalSocketAddress addr) throws IOException { }
+ void localConnect (LocalSocketAddress addr) throws IOException { }
+ int read (byte[] buf, int off, int len) throws IOException { return -1; }
+ void write (byte[] buf, int off, int len) throws IOException { }
+
+ void doCreate () throws IOException
+ {
+ if (!created)
+ {
+ create (true);
+ }
+ }
+
+ LocalSocketAddress getLocalAddress ()
+ {
+ return local;
+ }
+
+ LocalSocketAddress getRemoteAddress ()
+ {
+ return remote;
+ }
+
+ protected InputStream getInputStream()
+ {
+ if (in == null)
+ {
+ in = new LocalInputStream (this);
+ }
+
+ return in;
+ }
+
+ protected OutputStream getOutputStream()
+ {
+ if (out == null)
+ {
+ out = new LocalOutputStream (this);
+ }
+
+ return out;
+ }
+
+ protected void accept (SocketImpl impl) throws IOException
+ {
+ if (! (impl instanceof LocalSocketImpl))
+ {
+ throw new IllegalArgumentException ("not a local socket");
+ }
+ accept ((LocalSocketImpl) impl);
+ }
+
+ protected void connect (String host, int port) throws IOException
+ {
+ throw new SocketException ("this is a local socket");
+ }
+
+ protected void connect (InetAddress addr, int port) throws IOException
+ {
+ throw new SocketException ("this is a local socket");
+ }
+
+ protected void connect(SocketAddress addr, int timeout) throws IOException
+ {
+ if (! (addr instanceof LocalSocketAddress))
+ {
+ throw new SocketException ("address is not local");
+ }
+ localConnect ((LocalSocketAddress) addr);
+ }
+
+ protected void bind (InetAddress addr, int port) throws IOException
+ {
+ throw new SocketException ("this is a local socket");
+ }
+
+ protected void bind (SocketAddress addr) throws IOException
+ {
+ if (! (addr instanceof LocalSocketAddress))
+ {
+ throw new SocketException ("address is not local");
+ }
+ localBind ((LocalSocketAddress) addr);
+ }
+
+// Inner classes.
+ // -------------------------------------------------------------------------
+
+ class LocalInputStream extends InputStream
+ {
+
+ // Field.
+ // -----------------------------------------------------------------------
+
+ private final LocalSocketImpl impl;
+
+ // Constructor.
+ // -----------------------------------------------------------------------
+
+ LocalInputStream (LocalSocketImpl impl)
+ {
+ this.impl = impl;
+ }
+
+ // Instance methods.
+ // -----------------------------------------------------------------------
+
+ public int available () throws IOException
+ {
+ return impl.available();
+ }
+
+ public boolean markSupported ()
+ {
+ return false;
+ }
+
+ public void mark (int readLimit)
+ {
+ }
+
+ public void reset () throws IOException
+ {
+ throw new IOException ("mark/reset not supported");
+ }
+
+ public void close () throws IOException
+ {
+ impl.close();
+ }
+
+ public int read () throws IOException
+ {
+ byte[] buf = new byte[1];
+ int ret = read (buf);
+ if (ret != -1)
+ {
+ return buf[0] & 0xFF;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ public int read (byte[] buf) throws IOException
+ {
+ return read (buf, 0, buf.length);
+ }
+
+ public int read (byte[] buf, int off, int len) throws IOException
+ {
+ int ret = impl.read (buf, off, len);
+
+ if (ret == 0)
+ {
+ return -1;
+ }
+
+ return ret;
+ }
+ }
+
+ class LocalOutputStream extends OutputStream
+ {
+
+ // Field.
+ // -----------------------------------------------------------------------
+
+ private final LocalSocketImpl impl;
+
+ // Constructor.
+ // -----------------------------------------------------------------------
+
+ LocalOutputStream (LocalSocketImpl impl)
+ {
+ this.impl = impl;
+ }
+
+ // Instance methods.
+ // -----------------------------------------------------------------------
+
+ public void close () throws IOException
+ {
+ impl.close ();
+ }
+
+ public void flush () throws IOException
+ {
+ }
+
+ public void write (int b) throws IOException
+ {
+ byte[] buf = new byte [1];
+ buf[0] = (byte) b;
+ write (buf);
+ }
+
+ public void write (byte[] buf) throws IOException
+ {
+ write (buf, 0, buf.length);
+ }
+
+ public void write (byte[] buf, int off, int len) throws IOException
+ {
+ impl.write (buf, off, len);
+ }
+ }
+}
Index: gcj/javaprims.h
===================================================================
--- gcj/javaprims.h (revision 113842)
+++ gcj/javaprims.h (working copy)
@@ -55,10 +55,13 @@
class CharArrayReader;
class CharArrayWriter;
class CharConversionException;
+ class Closeable;
class DataInput;
class DataInputStream;
class DataOutput;
class DataOutputStream;
+ class DeleteFileHelper;
+ class DeleteFileHelper$1;
class EOFException;
class Externalizable;
class File;
@@ -75,6 +78,7 @@
class FilterOutputStream;
class FilterReader;
class FilterWriter;
+ class Flushable;
class IOException;
class InputStream;
class InputStreamReader;
@@ -87,18 +91,24 @@
class NotSerializableException;
class ObjectInput;
class ObjectInputStream;
+ class ObjectInputStream$1;
+ class ObjectInputStream$2;
class ObjectInputStream$GetField;
class ObjectInputStream$ValidatorAndPriority;
class ObjectInputValidation;
class ObjectOutput;
class ObjectOutputStream;
+ class ObjectOutputStream$1;
class ObjectOutputStream$PutField;
class ObjectStreamClass;
+ class ObjectStreamClass$1;
+ class ObjectStreamClass$2;
class ObjectStreamClass$InterfaceComparator;
class ObjectStreamClass$MemberComparator;
class ObjectStreamConstants;
class ObjectStreamException;
class ObjectStreamField;
+ class ObjectStreamField$1;
class OptionalDataException;
class OutputStream;
class OutputStreamWriter;
@@ -131,6 +141,7 @@
namespace lang
{
class AbstractMethodError;
+ class Appendable;
class ArithmeticException;
class ArrayIndexOutOfBoundsException;
class ArrayStoreException;
@@ -155,6 +166,8 @@
class ConcreteProcess$EOFInputStream;
class ConcreteProcess$ProcessManager;
class Double;
+ class Enum;
+ class EnumConstantNotPresentException;
class Error;
class Exception;
class ExceptionInInitializerError;
@@ -173,6 +186,7 @@
class Integer;
class InternalError;
class InterruptedException;
+ class Iterable;
class LinkageError;
class Long;
class Math;
@@ -189,6 +203,7 @@
class OutOfMemoryError;
class Package;
class Process;
+ class Readable;
class Runnable;
class Runtime;
class RuntimeException;
@@ -207,11 +222,13 @@
class StringIndexOutOfBoundsException;
class System;
class Thread;
+ class Thread$UncaughtExceptionHandler;
class ThreadDeath;
class ThreadGroup;
class ThreadLocal;
class Throwable;
class Throwable$StaticData;
+ class TypeNotPresentException;
class UnknownError;
class UnsatisfiedLinkError;
class UnsupportedClassVersionError;
@@ -225,6 +242,22 @@
class VerifyError;
class VirtualMachineError;
class Void;
+ namespace annotation
+ {
+ class Annotation;
+ class AnnotationFormatError;
+ class AnnotationTypeMismatchException;
+ }
+
+ namespace instrument
+ {
+ class ClassDefinition;
+ class ClassFileTransformer;
+ class IllegalClassFormatException;
+ class Instrumentation;
+ class UnmodifiableClassException;
+ }
+
namespace ref
{
class PhantomReference;
@@ -237,21 +270,31 @@
namespace reflect
{
class AccessibleObject;
+ class AnnotatedElement;
class Array;
class Constructor;
class Field;
+ class GenericArrayType;
+ class GenericDeclaration;
+ class GenericSignatureFormatError;
class InvocationHandler;
class InvocationTargetException;
+ class MalformedParameterizedTypeException;
class Member;
class Method;
class Modifier;
+ class ParameterizedType;
class Proxy;
class Proxy$ClassFactory;
class Proxy$ProxyData;
class Proxy$ProxySignature;
class Proxy$ProxyType;
class ReflectPermission;
+ class Type;
+ class TypeVariable;
class UndeclaredThrowableException;
+ class VMProxy;
+ class WildcardType;
}
}
@@ -259,9 +302,16 @@
{
class AbstractCollection;
class AbstractList;
+ class AbstractList$1;
+ class AbstractList$2;
class AbstractList$RandomAccessSubList;
class AbstractList$SubList;
+ class AbstractList$SubList$3;
class AbstractMap;
+ class AbstractMap$1;
+ class AbstractMap$1$2;
+ class AbstractMap$3;
+ class AbstractMap$3$4;
class AbstractMap$BasicMapEntry;
class AbstractSequentialList;
class AbstractSet;
@@ -272,6 +322,7 @@
class Calendar;
class Collection;
class Collections;
+ class Collections$1;
class Collections$CopiesList;
class Collections$EmptyList;
class Collections$EmptyMap;
@@ -279,23 +330,29 @@
class Collections$ReverseComparator;
class Collections$SingletonList;
class Collections$SingletonMap;
+ class Collections$SingletonMap$3;
class Collections$SingletonSet;
+ class Collections$SingletonSet$2;
class Collections$SynchronizedCollection;
class Collections$SynchronizedIterator;
class Collections$SynchronizedList;
class Collections$SynchronizedListIterator;
class Collections$SynchronizedMap;
- class Collections$SynchronizedMapEntry;
+ class Collections$SynchronizedMap$4$SynchronizedMapEntry;
+ class Collections$SynchronizedMap$5;
+ class Collections$SynchronizedMap$5$6;
class Collections$SynchronizedRandomAccessList;
class Collections$SynchronizedSet;
class Collections$SynchronizedSortedMap;
class Collections$SynchronizedSortedSet;
class Collections$UnmodifiableCollection;
- class Collections$UnmodifiableEntrySet;
class Collections$UnmodifiableIterator;
class Collections$UnmodifiableList;
class Collections$UnmodifiableListIterator;
class Collections$UnmodifiableMap;
+ class Collections$UnmodifiableMap$UnmodifiableEntrySet;
+ class Collections$UnmodifiableMap$UnmodifiableEntrySet$7;
+ class Collections$UnmodifiableMap$UnmodifiableEntrySet$7$8;
class Collections$UnmodifiableRandomAccessList;
class Collections$UnmodifiableSet;
class Collections$UnmodifiableSortedMap;
@@ -312,18 +369,33 @@
class EventObject;
class GregorianCalendar;
class HashMap;
+ class HashMap$1;
+ class HashMap$2;
+ class HashMap$3;
class HashMap$HashEntry;
class HashMap$HashIterator;
class HashSet;
class Hashtable;
- class Hashtable$Enumerator;
+ class Hashtable$1;
+ class Hashtable$2;
+ class Hashtable$3;
+ class Hashtable$EntryEnumerator;
+ class Hashtable$EntryIterator;
class Hashtable$HashEntry;
- class Hashtable$HashIterator;
+ class Hashtable$KeyEnumerator;
+ class Hashtable$KeyIterator;
+ class Hashtable$ValueEnumerator;
+ class Hashtable$ValueIterator;
class IdentityHashMap;
+ class IdentityHashMap$1;
+ class IdentityHashMap$2;
+ class IdentityHashMap$3;
class IdentityHashMap$IdentityEntry;
class IdentityHashMap$IdentityIterator;
+ class InvalidPropertiesFormatException;
class Iterator;
class LinkedHashMap;
+ class LinkedHashMap$1;
class LinkedHashMap$LinkedHashEntry;
class LinkedHashSet;
class LinkedList;
@@ -335,9 +407,7 @@
class Locale;
class Map;
class Map$Entry;
- class Map$Map;
class MissingResourceException;
- class MyResources;
class NoSuchElementException;
class Observable;
class Observer;
@@ -356,22 +426,32 @@
class Stack;
class StringTokenizer;
class TimeZone;
+ class TimeZone$1;
class Timer;
class Timer$Scheduler;
class Timer$TaskQueue;
class TimerTask;
class TooManyListenersException;
class TreeMap;
+ class TreeMap$1;
+ class TreeMap$2;
+ class TreeMap$3;
class TreeMap$Node;
class TreeMap$SubMap;
+ class TreeMap$SubMap$4;
+ class TreeMap$SubMap$5;
+ class TreeMap$SubMap$6;
class TreeMap$TreeIterator;
class TreeSet;
class VMTimeZone;
class Vector;
+ class Vector$1;
class WeakHashMap;
+ class WeakHashMap$1;
class WeakHashMap$WeakBucket;
- class WeakHashMap$WeakEntry;
+ class WeakHashMap$WeakBucket$WeakEntry;
class WeakHashMap$WeakEntrySet;
+ class WeakHashMap$WeakEntrySet$2;
namespace jar
{
class Attributes;
@@ -391,6 +471,7 @@
class ConsoleHandler;
class ErrorManager;
class FileHandler;
+ class FileHandler$ostr;
class Filter;
class Formatter;
class Handler;
@@ -398,6 +479,7 @@
class LogManager;
class LogRecord;
class Logger;
+ class Logger$1;
class LoggingPermission;
class MemoryHandler;
class SimpleFormatter;
@@ -409,6 +491,8 @@
namespace prefs
{
class AbstractPreferences;
+ class AbstractPreferences$1;
+ class AbstractPreferences$2;
class BackingStoreException;
class InvalidPreferencesFormatException;
class NodeChangeEvent;
@@ -416,11 +500,13 @@
class PreferenceChangeEvent;
class PreferenceChangeListener;
class Preferences;
+ class Preferences$1;
class PreferencesFactory;
}
namespace regex
{
+ class MatchResult;
class Matcher;
class Pattern;
class PatternSyntaxException;
@@ -444,6 +530,7 @@
class ZipEntry;
class ZipException;
class ZipFile;
+ class ZipFile$1;
class ZipFile$PartialInputStream;
class ZipFile$ZipEntryEnumeration;
class ZipInputStream;
Index: java/lang/natMath.cc
===================================================================
--- java/lang/natMath.cc (revision 113842)
+++ java/lang/natMath.cc (working copy)
@@ -102,6 +102,11 @@
return (jdouble)::ceil((double)x);
}
+jdouble java::lang::Math::log10(jdouble x)
+{
+ return (jdouble)::log10((double)x);
+}
+
static inline int
floatToIntBits (jfloat value)
{
Index: java/lang/Thread.java
===================================================================
--- java/lang/Thread.java (revision 113842)
+++ java/lang/Thread.java (working copy)
@@ -127,11 +127,17 @@
/** The context classloader for this Thread. */
private ClassLoader contextClassLoader;
+ /** The default exception handler. */
+ private static UncaughtExceptionHandler defaultHandler;
+
/** Thread local storage. Package accessible for use by
* InheritableThreadLocal.
*/
WeakIdentityHashMap locals;
+ /** The uncaught exception handler. */
+ UncaughtExceptionHandler exceptionHandler;
+
// This describes the top-most interpreter frame for this thread.
RawData interp_frame;
@@ -935,4 +941,159 @@
}
return locals;
}
+
+ /**
+ * Assigns the given UncaughtExceptionHandler
to this
+ * thread. This will then be called if the thread terminates due
+ * to an uncaught exception, pre-empting that of the
+ * ThreadGroup
.
+ *
+ * @param h the handler to use for this thread.
+ * @throws SecurityException if the current thread can't modify this thread.
+ * @since 1.5
+ */
+ public void setUncaughtExceptionHandler(UncaughtExceptionHandler h)
+ {
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
+ if (sm != null)
+ sm.checkAccess(this);
+ exceptionHandler = h;
+ }
+
+ /**
+ *
+ * Returns the handler used when this thread terminates due to an + * uncaught exception. The handler used is determined by the following: + *
+ *ThreadGroup
+ * object is returned.null
is returned
+ * (which can only happen when the thread was terminated since
+ * then it won't have an associated thread group anymore).UncaughtExceptionHandler
or
+ * null
if one can't be obtained.
+ * @since 1.5
+ */
+ public UncaughtExceptionHandler getUncaughtExceptionHandler()
+ {
+ return exceptionHandler != null ? exceptionHandler : group;
+ }
+
+ /**
+ *
+ * Sets the default uncaught exception handler used when one isn't
+ * provided by the thread or its associated ThreadGroup
.
+ * This exception handler is used when the thread itself does not
+ * have an exception handler, and the thread's ThreadGroup
+ * does not override this default mechanism with its own. As the group
+ * calls this handler by default, this exception handler should not defer
+ * to that of the group, as it may lead to infinite recursion.
+ *
+ * Uncaught exception handlers are used when a thread terminates due to + * an uncaught exception. Replacing this handler allows default code to + * be put in place for all threads in order to handle this eventuality. + *
+ * + * @param h the new default uncaught exception handler to use. + * @throws SecurityException if a security manager is present and + * disallows the runtime permission + * "setDefaultUncaughtExceptionHandler". + * @since 1.5 + */ + public static void + setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler h) + { + SecurityManager sm = SecurityManager.current; // Be thread-safe. + if (sm != null) + sm.checkPermission(new RuntimePermission("setDefaultUncaughtExceptionHandler")); + defaultHandler = h; + } + + /** + * Returns the handler used by default when a thread terminates + * unexpectedly due to an exception, ornull
if one doesn't
+ * exist.
+ *
+ * @return the default uncaught exception handler.
+ * @since 1.5
+ */
+ public static UncaughtExceptionHandler getDefaultUncaughtExceptionHandler()
+ {
+ return defaultHandler;
+ }
+
+ /**
+ * Returns the unique identifier for this thread. This ID is generated
+ * on thread creation, and may be re-used on its death.
+ *
+ * @return a positive long number representing the thread's ID.
+ * @since 1.5
+ public long getId()
+ {
+ return threadId;
+ }
+ */
+
+ /**
+ *
+ * This interface is used to handle uncaught exceptions
+ * which cause a Thread
to terminate. When
+ * a thread, t, is about to terminate due to an uncaught
+ * exception, the virtual machine looks for a class which
+ * implements this interface, in order to supply it with
+ * the dying thread and its uncaught exception.
+ *
+ * The virtual machine makes two attempts to find an + * appropriate handler for the uncaught exception, in + * the following order: + *
+ *t.getUncaughtExceptionHandler()
--
+ * the dying thread is queried first for a handler
+ * specific to that thread.
+ * t.getThreadGroup()
--
+ * the thread group of the dying thread is used to
+ * handle the exception. If the thread group has
+ * no special requirements for handling the exception,
+ * it may simply forward it on to
+ * Thread.getDefaultUncaughtExceptionHandler()
,
+ * the default handler, which is used as a last resort.
+ * + * The first handler found is the one used to handle + * the uncaught exception. + *
+ * + * @author Tom TromeyTypeVariable
objects that represents
+ * the type variables declared by this constructor, in declaration order.
+ * An array of size zero is returned if this class has no type
+ * variables.
+ *
+ * @return the type variables associated with this class.
+ * @throws GenericSignatureFormatError if the generic signature does
+ * not conform to the format specified in the Virtual Machine
+ * specification, version 3.
+ * @since 1.5
+ */
+ /* FIXME[GENERICS]: Should be TypeVariableTypeVariable
objects that represents
+ * the type variables declared by this constructor, in declaration order.
+ * An array of size zero is returned if this class has no type
+ * variables.
+ *
+ * @return the type variables associated with this class.
+ * @throws GenericSignatureFormatError if the generic signature does
+ * not conform to the format specified in the Virtual Machine
+ * specification, version 3.
+ * @since 1.5
+ */
+ /* FIXME[GENERICS]: Should be TypeVariablegetName()
which follows the last ".". Anonymous
+ * classes have no name, and so the result of calling this method is
+ * "". The simple name of an array consists of the simple name of
+ * its component type, followed by "[]". Thus, an array with the
+ * component type of an anonymous class has a simple name of simply
+ * "[]".
+ *
+ * @return the simple name for this class.
+ * @since 1.5
+ */
+ public String getSimpleName()
+ {
+ // FIXME write real implementation
+ return "";
+ }
+
+ /**
+ * Returns the class which immediately encloses this class. If this class
+ * is a top-level class, this method returns null
.
+ *
+ * @return the immediate enclosing class, or null
if this is
+ * a top-level class.
+ * @since 1.5
+ */
+ /* FIXME[GENERICS]: Should return Class> */
+ public Class getEnclosingClass()
+ {
+ // FIXME write real implementation
+ return null;
+ }
+
+ /**
+ * Returns the constructor which immediately encloses this class. If
+ * this class is a top-level class, or a local or anonymous class
+ * immediately enclosed by a type definition, instance initializer
+ * or static initializer, then null
is returned.
+ *
+ * @return the immediate enclosing constructor if this class is
+ * declared within a constructor. Otherwise, null
+ * is returned.
+ * @since 1.5
+ */
+ /* FIXME[GENERICS]: Should return Constructor> */
+ public Constructor getEnclosingConstructor()
+ {
+ // FIXME write real implementation
+ return null;
+ }
+
+ /**
+ * Returns the method which immediately encloses this class. If
+ * this class is a top-level class, or a local or anonymous class
+ * immediately enclosed by a type definition, instance initializer
+ * or static initializer, then null
is returned.
+ *
+ * @return the immediate enclosing method if this class is
+ * declared within a method. Otherwise, null
+ * is returned.
+ * @since 1.5
+ */
+ public Method getEnclosingMethod()
+ {
+ // FIXME write real implementation
+ return null;
+ }
+
+ /**
+ * Returns an array of TypeVariable
objects that represents
+ * the type variables declared by this class, in declaration order.
+ * An array of size zero is returned if this class has no type
+ * variables.
+ *
+ * @return the type variables associated with this class.
+ * @throws GenericSignatureFormatError if the generic signature does
+ * not conform to the format specified in the Virtual Machine
+ * specification, version 3.
+ * @since 1.5
+ */
+ /* FIXME[GENERICS]: Should return TypeVariable+ * Returns the base 10 logarithm of the supplied value. The returned + * result is within 1 ulp of the exact result, and the results are + * semi-monotonic. + *
+ *
+ * Arguments of either NaN
or less than zero return
+ * NaN
. An argument of positive infinity returns positive
+ * infinity. Negative infinity is returned if either positive or negative
+ * zero is supplied. Where the argument is the result of
+ * 10n, then
n
is returned.
+ *
a
.
+ * @since 1.5
+ */
+ public static native double log10(double a);
+
+ /**
+ * + * Returns the sign of the argument as follows: + *
+ *a
is greater than zero, the result is 1.0.a
is less than zero, the result is -1.0.a
is NaN
, the result is NaN
.
+ * a
is positive or negative zero, the result is the
+ * same.+ * Returns the sign of the argument as follows: + *
+ *a
is greater than zero, the result is 1.0f.a
is less than zero, the result is -1.0f.a
is NaN
, the result is NaN
.
+ * a
is positive or negative zero, the result is the
+ * same.The default implementation of this class runs eight threads that
+ * increment counters in a tight loop, and XORs each counter to
+ * produce one byte of seed data. This is not very efficient, and is
+ * not guaranteed to be random (the thread scheduler is probably
+ * deterministic, after all). If possible, VM implementors should
+ * reimplement this class so it obtains a random seed from a system
+ * facility, such as a system entropy gathering device or hardware
+ * random number generator.
+ */
+final class VMSecureRandom
+{
+
+ /**
+ * Generate a random seed. Implementations are free to generate
+ * fewer random bytes than are requested, and leave the remaining
+ * bytes of the destination buffer as zeros. Implementations SHOULD,
+ * however, make a best-effort attempt to satisfy the request.
+ *
+ * @param buffer The destination buffer.
+ * @param offset The offset in the buffer to start putting bytes.
+ * @param length The number of random bytes to generate.
+ */
+ static int generateSeed(byte[] buffer, int offset, int length)
+ {
+ if (length < 0)
+ throw new IllegalArgumentException("length must be nonnegative");
+ if (offset < 0 || offset + length > buffer.length)
+ throw new IndexOutOfBoundsException();
+
+ Spinner[] spinners = new Spinner[8];
+ int n = 0x1;
+ for (int i = 0; i < spinners.length; i++)
+ {
+ spinners[i] = new Spinner((byte) n);
+ Thread t = new Thread(spinners[i]);
+ t.start();
+ n <<= 1;
+ }
+
+ // Wait until at least one spinner has started.
+ while (!(spinners[0].running || spinners[1].running || spinners[2].running
+ || spinners[3].running || spinners[4].running || spinners[5].running
+ || spinners[6].running || spinners[7].running))
+ {
+ Thread.yield();
+ }
+
+ for (int i = offset; i < length; i++)
+ {
+ buffer[i] = (byte) (spinners[0].value ^ spinners[1].value ^ spinners[2].value
+ ^ spinners[3].value ^ spinners[4].value ^ spinners[5].value
+ ^ spinners[6].value ^ spinners[7].value);
+ Thread.yield();
+ }
+
+ for (int i = 0; i < spinners.length; i++)
+ spinners[i].stop();
+
+ return length;
+ }
+
+ static class Spinner implements Runnable
+ {
+ volatile byte value;
+ volatile boolean running;
+
+ Spinner(final byte initial)
+ {
+ value = initial;
+ }
+
+ public void run()
+ {
+ running = true;
+ while (running)
+ value++;
+ }
+
+ private void stop()
+ {
+ running = false;
+ }
+ }
+}
\ No newline at end of file
Index: java/util/logging/Logger.java
===================================================================
--- java/util/logging/Logger.java (revision 113842)
+++ java/util/logging/Logger.java (working copy)
@@ -1,5 +1,5 @@
/* Logger.java -- a class for logging messages
- Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,8 @@
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
/**
* A Logger is used for logging information about events. Usually, there
@@ -67,15 +69,31 @@
*/
public class Logger
{
+
+ static final Logger root = new Logger("", null);
+
/**
* A logger provided to applications that make only occasional use
* of the logging framework, typically early prototypes. Serious
* products are supposed to create and use their own Loggers, so
* they can be controlled individually.
*/
- public static final Logger global = getLogger("global");
+ public static final Logger global;
+ static
+ {
+ // Our class might be initialized from an unprivileged context
+ global = (Logger) AccessController.doPrivileged
+ (new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return getLogger("global");
+ }
+ });
+ }
+
/**
* The name of the Logger, or null
if the logger is
* anonymous.
@@ -175,7 +193,7 @@
/* This is null when the root logger is being constructed,
* and the root logger afterwards.
*/
- parent = LogManager.getLogManager().rootLogger;
+ parent = root;
useParentHandlers = (parent != null);
}
@@ -577,7 +595,8 @@
public void log(Level level, String message)
{
- log(level, message, (Object[]) null);
+ if (isLoggable(level))
+ log(level, message, (Object[]) null);
}
@@ -585,12 +604,15 @@
String message,
Object param)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller.getClassName(),
- caller.getMethodName(),
- message,
- param);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level,
+ caller != null ? caller.getClassName() : "