Imported GNU Classpath 0.90

Imported GNU Classpath 0.90
       * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore.
       * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant.
       * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5.
       * java/lang/Math.java: New override file.
       * java/lang/Character.java: Merged from Classpath.
       (start, end): Now 'int's.
       (canonicalName): New field.
       (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants.
       (UnicodeBlock): Added argument.
       (of): New overload.
       (forName): New method.
       Updated unicode blocks.
       (sets): Updated.
       * sources.am: Regenerated.
       * Makefile.in: Likewise.

From-SVN: r111942
This commit is contained in:
Mark Wielaard
2006-03-10 21:46:48 +00:00
parent 27079765d0
commit 8aa540d2f7
1367 changed files with 188789 additions and 22762 deletions
@@ -1,5 +1,5 @@
/* AbstractPreferences -- Partial implementation of a Preference node
Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,11 +38,13 @@ exception statement from your version. */
package java.util.prefs;
import gnu.java.util.prefs.EventDispatcher;
import gnu.java.util.prefs.NodeWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.TreeSet;
@@ -68,7 +70,7 @@ public abstract class AbstractPreferences extends Preferences {
/**
* Set to true in the contructor if the node did not exist in the backing
* store when this preference node object was created. Should be set in
* the contructor of a subclass. Defaults to false. Used to fire node
* the constructor of a subclass. Defaults to false. Used to fire node
* changed events.
*/
protected boolean newNode = false;
@@ -97,6 +99,16 @@ public abstract class AbstractPreferences extends Preferences {
*/
private HashMap childCache = new HashMap();
/**
* A list of all the registered NodeChangeListener objects.
*/
private ArrayList nodeListeners;
/**
* A list of all the registered PreferenceChangeListener objects.
*/
private ArrayList preferenceListeners;
// constructor
/**
@@ -256,7 +268,7 @@ public abstract class AbstractPreferences extends Preferences {
* @exception IllegalArgumentException if the path contains two or more
* consecutive '/' characters, ends with a '/' charactor and is not the
* string "/" (indicating the root node) or any name on the path is more
* then 80 characters long
* than 80 characters long
*/
public Preferences node(String path) {
synchronized(lock) {
@@ -325,8 +337,9 @@ public abstract class AbstractPreferences extends Preferences {
// Not in childCache yet so create a new sub node
child = childSpi(childName);
// XXX - check if node is new
childCache.put(childName, child);
if (child.newNode && nodeListeners != null)
fire(new NodeChangeEvent(this, child), true);
}
// Lock the child and go down
@@ -477,9 +490,7 @@ public abstract class AbstractPreferences extends Preferences {
// export methods
/**
* XXX
*/
// Inherit javadoc.
public void exportNode(OutputStream os)
throws BackingStoreException,
IOException
@@ -488,9 +499,7 @@ public abstract class AbstractPreferences extends Preferences {
nodeWriter.writePrefs();
}
/**
* XXX
*/
// Inherit javadoc.
public void exportSubtree(OutputStream os)
throws BackingStoreException,
IOException
@@ -765,8 +774,8 @@ public abstract class AbstractPreferences extends Preferences {
* Key and value cannot be null, the key cannot exceed 80 characters
* and the value cannot exceed 8192 characters.
* <p>
* The result will be immediatly visible in this VM, but may not be
* immediatly written to the backing store.
* The result will be immediately visible in this VM, but may not be
* immediately written to the backing store.
* <p>
* Checks that key and value are valid, locks this node, and checks that
* the node has not been removed. Then it calls <code>putSpi()</code>.
@@ -789,7 +798,8 @@ public abstract class AbstractPreferences extends Preferences {
putSpi(key, value);
// XXX - fire events
if (preferenceListeners != null)
fire(new PreferenceChangeEvent(this, key, value));
}
}
@@ -804,9 +814,7 @@ public abstract class AbstractPreferences extends Preferences {
* @exception IllegalStateException when this node has been removed
*/
public void putBoolean(String key, boolean value) {
put(key, String.valueOf(value));
// XXX - Use when using 1.4 compatible Boolean
// put(key, Boolean.toString(value));
put(key, Boolean.toString(value));
}
/**
@@ -935,8 +943,8 @@ public abstract class AbstractPreferences extends Preferences {
/**
* Removes the preferences entry from this preferences node.
* <p>
* The result will be immediatly visible in this VM, but may not be
* immediatly written to the backing store.
* The result will be immediately visible in this VM, but may not be
* immediately written to the backing store.
* <p>
* This implementation checks that the key is not larger then 80
* characters, gets the lock of this node, checks that the node has
@@ -955,6 +963,9 @@ public abstract class AbstractPreferences extends Preferences {
throw new IllegalStateException("Node removed");
removeSpi(key);
if (preferenceListeners != null)
fire(new PreferenceChangeEvent(this, key, null));
}
}
@@ -962,7 +973,7 @@ public abstract class AbstractPreferences extends Preferences {
* Removes all entries from this preferences node. May need access to the
* backing store to get and clear all entries.
* <p>
* The result will be immediatly visible in this VM, but may not be
* The result will be immediately visible in this VM, but may not be
* immediatly written to the backing store.
* <p>
* This implementation locks this node, checks that the node has not been
@@ -1049,7 +1060,7 @@ public abstract class AbstractPreferences extends Preferences {
for (int i = 0; i < keys.length; i++) {
// Have to lock this node again to access the childCache
AbstractPreferences subNode;
synchronized(this) {
synchronized(lock) {
subNode = (AbstractPreferences) childCache.get(keys[i]);
}
@@ -1087,8 +1098,8 @@ public abstract class AbstractPreferences extends Preferences {
if (parent == null)
throw new UnsupportedOperationException("Cannot remove root node");
synchronized(parent) {
synchronized(this) {
synchronized (parent.lock) {
synchronized(this.lock) {
if (isRemoved())
throw new IllegalStateException("Node Removed");
@@ -1122,7 +1133,7 @@ public abstract class AbstractPreferences extends Preferences {
Iterator i = childCache.values().iterator();
while (i.hasNext()) {
AbstractPreferences node = (AbstractPreferences) i.next();
synchronized(node) {
synchronized(node.lock) {
node.purge();
}
}
@@ -1134,30 +1145,131 @@ public abstract class AbstractPreferences extends Preferences {
removeNodeSpi();
removed = true;
// XXX - check for listeners
if (nodeListeners != null)
fire(new NodeChangeEvent(parent, this), false);
}
// listener methods
/**
* XXX
* Add a listener which is notified when a sub-node of this node
* is added or removed.
* @param listener the listener to add
*/
public void addNodeChangeListener(NodeChangeListener listener) {
// XXX
}
public void addPreferenceChangeListener(PreferenceChangeListener listener) {
// XXX
}
public void removeNodeChangeListener(NodeChangeListener listener) {
// XXX
}
public void removePreferenceChangeListener
(PreferenceChangeListener listener)
public void addNodeChangeListener(NodeChangeListener listener)
{
// XXX
synchronized (lock)
{
if (isRemoved())
throw new IllegalStateException("node has been removed");
if (listener == null)
throw new NullPointerException("listener is null");
if (nodeListeners == null)
nodeListeners = new ArrayList();
nodeListeners.add(listener);
}
}
/**
* Add a listener which is notified when a value in this node
* is added, changed, or removed.
* @param listener the listener to add
*/
public void addPreferenceChangeListener(PreferenceChangeListener listener)
{
synchronized (lock)
{
if (isRemoved())
throw new IllegalStateException("node has been removed");
if (listener == null)
throw new NullPointerException("listener is null");
if (preferenceListeners == null)
preferenceListeners = new ArrayList();
preferenceListeners.add(listener);
}
}
/**
* Remove the indicated node change listener from the list of
* listeners to notify.
* @param listener the listener to remove
*/
public void removeNodeChangeListener(NodeChangeListener listener)
{
synchronized (lock)
{
if (isRemoved())
throw new IllegalStateException("node has been removed");
if (listener == null)
throw new NullPointerException("listener is null");
if (nodeListeners != null)
nodeListeners.remove(listener);
}
}
/**
* Remove the indicated preference change listener from the list of
* listeners to notify.
* @param listener the listener to remove
*/
public void removePreferenceChangeListener (PreferenceChangeListener listener)
{
synchronized (lock)
{
if (isRemoved())
throw new IllegalStateException("node has been removed");
if (listener == null)
throw new NullPointerException("listener is null");
if (preferenceListeners != null)
preferenceListeners.remove(listener);
}
}
/**
* Send a preference change event to all listeners. Note that
* the caller is responsible for holding the node's lock, and
* for checking that the list of listeners is not null.
* @param event the event to send
*/
private void fire(final PreferenceChangeEvent event)
{
Iterator it = preferenceListeners.iterator();
while (it.hasNext())
{
final PreferenceChangeListener l = (PreferenceChangeListener) it.next();
EventDispatcher.dispatch(new Runnable()
{
public void run()
{
l.preferenceChange(event);
}
});
}
}
/**
* Send a node change event to all listeners. Note that
* the caller is responsible for holding the node's lock, and
* for checking that the list of listeners is not null.
* @param event the event to send
*/
private void fire(final NodeChangeEvent event, final boolean added)
{
Iterator it = nodeListeners.iterator();
while (it.hasNext())
{
final NodeChangeListener l = (NodeChangeListener) it.next();
EventDispatcher.dispatch(new Runnable()
{
public void run()
{
if (added)
l.childAdded(event);
else
l.childRemoved(event);
}
});
}
}
// abstract spi methods
@@ -1214,7 +1326,7 @@ public abstract class AbstractPreferences extends Preferences {
/**
* Sets the value of the given preferences entry for this node.
* The implementation is not required to propagate the change to the
* backing store immediatly. It may not throw an exception when it tries
* backing store immediately. It may not throw an exception when it tries
* to write to the backing store and that operation fails, the failure
* should be registered so a later invocation of <code>flush()</code>
* or <code>sync()</code> can signal the failure.
@@ -1227,7 +1339,7 @@ public abstract class AbstractPreferences extends Preferences {
/**
* Removes the given key entry from this preferences node.
* The implementation is not required to propagate the change to the
* backing store immediatly. It may not throw an exception when it tries
* backing store immediately. It may not throw an exception when it tries
* to write to the backing store and that operation fails, the failure
* should be registered so a later invocation of <code>flush()</code>
* or <code>sync()</code> can signal the failure.
@@ -1,5 +1,5 @@
/* NodeChangeEvent - ObjectEvent fired when a Preference node is added/removed
Copyright (C) 2001 Free Software Foundation, Inc.
Copyright (C) 2001, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,6 +37,10 @@ exception statement from your version. */
package java.util.prefs;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.EventObject;
/**
@@ -44,12 +48,16 @@ import java.util.EventObject;
* This event is only generated when a new subnode is added or a subnode is
* removed from a preference node. Changes in the entries of a preference node
* are indicated with a <code>PreferenceChangeEvent</code>.
* <p>
* Note that although this class is marked as serializable, attempts to
* serialize it will fail with NotSerializableException.
*
* @since 1.4
* @author Mark Wielaard (mark@klomp.org)
*/
public class NodeChangeEvent extends EventObject {
// We have this to placate the compiler.
private static final long serialVersionUID =8068949086596572957L;
/**
@@ -88,4 +96,16 @@ public class NodeChangeEvent extends EventObject {
public Preferences getChild() {
return child;
}
private void readObject(ObjectInputStream ois)
throws IOException
{
throw new NotSerializableException("LineEvent is not serializable");
}
private void writeObject(ObjectOutputStream oos)
throws IOException
{
throw new NotSerializableException("LineEvent is not serializable");
}
}
@@ -1,5 +1,5 @@
/* PreferenceChangeEvent - ObjectEvent fired when a Preferences entry changes
Copyright (C) 2001 Free Software Foundation, Inc.
Copyright (C) 2001, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,6 +37,10 @@ exception statement from your version. */
package java.util.prefs;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.EventObject;
/**
@@ -47,12 +51,16 @@ import java.util.EventObject;
* Preference change events are only generated for entries in one particular
* preference node. Notification of subnode addition/removal is given by a
* <code>NodeChangeEvent</code>.
* <p>
* Note that although this class is marked as serializable, attempts to
* serialize it will fail with NotSerializableException.
*
* @since 1.4
* @author Mark Wielaard (mark@klomp.org)
*/
public class PreferenceChangeEvent extends EventObject {
// We have this to placate the compiler.
private static final long serialVersionUID = 793724513368024975L;
/**
@@ -102,4 +110,16 @@ public class PreferenceChangeEvent extends EventObject {
public String getNewValue() {
return newValue;
}
private void readObject(ObjectInputStream ois)
throws IOException
{
throw new NotSerializableException("LineEvent is not serializable");
}
private void writeObject(ObjectOutputStream oos)
throws IOException
{
throw new NotSerializableException("LineEvent is not serializable");
}
}
@@ -1,5 +1,5 @@
/* Preferences -- Preference node containing key value entries and subnodes
Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -90,12 +90,9 @@ public abstract class Preferences {
/**
* Default PreferencesFactory class used when the system property
* "java.util.prefs.PreferencesFactory" is not set.
* <p>
* XXX - Currently set to MemoryBasedFactory, should be changed
* when FileBasedPreferences backend works.
*/
private static final String defaultFactoryClass
= "gnu.java.util.prefs.MemoryBasedFactory";
= "gnu.java.util.prefs.FileBasedFactory";
/** Permission needed to access system or user root. */
private static final Permission prefsPermission
@@ -219,8 +216,7 @@ public abstract class Preferences {
catch (Exception e)
{
throw new RuntimeException ("Couldn't load default factory"
+ " '"+ defaultFactoryClass +"'");
// XXX - when using 1.4 compatible throwables add cause
+ " '"+ defaultFactoryClass +"'", e);
}
}
@@ -288,7 +284,13 @@ public abstract class Preferences {
}
/**
* XXX
* Import preferences from the given input stream. This expects
* preferences to be represented in XML as emitted by
* {@link #exportNode(OutputStream)} and
* {@link #exportSubtree(OutputStream)}.
* @throws IOException if there is an error while reading
* @throws InvalidPreferencesFormatException if the XML is not properly
* formatted
*/
public static void importPreferences(InputStream is)
throws InvalidPreferencesFormatException,
@@ -385,14 +387,28 @@ public abstract class Preferences {
// abstract methods (export)
/**
* XXX
* Export this node, but not its descendants, as XML to the
* indicated output stream. The XML will be encoded using UTF-8
* and will use a specified document type:<br>
* <code>&lt;!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd"&gt;</code><br>
* @param os the output stream to which the XML is sent
* @throws BackingStoreException if preference data cannot be read
* @throws IOException if an error occurs while writing the XML
* @throws IllegalStateException if this node or an ancestor has been removed
*/
public abstract void exportNode(OutputStream os)
throws BackingStoreException,
IOException;
/**
* XXX
* Export this node and all its descendants as XML to the
* indicated output stream. The XML will be encoded using UTF-8
* and will use a specified document type:<br>
* <code>&lt;!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd"&gt;</code><br>
* @param os the output stream to which the XML is sent
* @throws BackingStoreException if preference data cannot be read
* @throws IOException if an error occurs while writing the XML
* @throws IllegalStateException if this node or an ancestor has been removed
*/
public abstract void exportSubtree(OutputStream os)
throws BackingStoreException,