Commit f18590c6 by Tom Tromey Committed by Tom Tromey

Externalizable.java, [...]: New versions from Classpath.

	* java/io/Externalizable.java, java/io/FilePermission.java,
	java/io/ObjectStreamConstants.java, java/io/Serializable.java,
	java/io/SerializablePermission.java, java/text/Format.java,
	java/util/AbstractMap.java, java/util/HashMap.java,
	java/util/LinkedHashMap.java, javax/naming/BinaryRefAddr.java: New
	versions from Classpath.

From-SVN: r58996
parent 99c49d11
2002-11-10 Tom Tromey <tromey@redhat.com>
* java/io/Externalizable.java, java/io/FilePermission.java,
java/io/ObjectStreamConstants.java, java/io/Serializable.java,
java/io/SerializablePermission.java, java/text/Format.java,
java/util/AbstractMap.java, java/util/HashMap.java,
java/util/LinkedHashMap.java, javax/naming/BinaryRefAddr.java: New
versions from Classpath.
2002-11-10 Anthony Green <green@redhat.com>
* java/util/jar/Attributes.java (Name): Fix name check.
......
......@@ -62,6 +62,7 @@ package java.io;
*/
public interface Externalizable extends Serializable
{
static final long serialVersionUID = -282491828744381764L;
/**
* This method restores an object's state by reading in the instance data
......
......@@ -41,7 +41,10 @@ package java.io;
import java.security.*;
public final class FilePermission extends Permission implements Serializable {
public final class FilePermission extends Permission implements Serializable
{
static final long serialVersionUID = 7930732926638008763L;
private static final String CURRENT_DIRECTORY = System.getProperty("user.dir");
private boolean usingPerms = false;
private boolean readPerm = false;
......
......@@ -70,7 +70,7 @@ public interface ObjectStreamConstants
final static byte TC_PROXYCLASSDESC = (byte)125; //0x7D
final static byte TC_BASE = TC_NULL;
final static byte TC_MAX = TC_EXCEPTION;
final static byte TC_MAX = TC_PROXYCLASSDESC;
final static int baseWireHandle = 0x7e0000;
......
......@@ -51,4 +51,5 @@ package java.io;
*/
public interface Serializable
{
static final long serialVersionUID = 1196656838076753133L;
} // interface Serializable
......@@ -61,7 +61,8 @@ import java.security.BasicPermission;
*/
public final class SerializablePermission extends BasicPermission
{
static final long serialVersionUID = 8537212141160296410L;
/*
* Class Variables
*/
......
......@@ -59,6 +59,8 @@ import java.io.Serializable;
*/
public abstract class Format implements Serializable, Cloneable
{
static final long serialVersionUID = -299282585814624189L;
/**
* This method initializes a new instance of <code>Format</code>.
* It performs no actions, but acts as a default constructor for
......
......@@ -466,6 +466,11 @@ public abstract class AbstractMap implements Map
return AbstractMap.this.size();
}
public boolean contains(Object value)
{
return containsValue(value);
}
public Iterator iterator()
{
return new Iterator()
......@@ -527,8 +532,9 @@ public abstract class AbstractMap implements Map
* @author Jon Zeppieri
* @author Eric Blake <ebb9@email.byu.edu>
*/
// XXX - FIXME Use fully qualified implements as gcj 3.1 workaround.
static class BasicMapEntry implements Map.Entry
{ // XXX - FIXME Use fully qualified implements as gcj 3.1 workaround.
{
/**
* The key. Package visible for direct manipulation.
*/
......@@ -553,16 +559,14 @@ public abstract class AbstractMap implements Map
/**
* Compares the specified object with this entry. Returns true only if
* the object is a mapping of identical key and value. In other words,
* this must be:
*
<pre>(o instanceof Map.Entry) &&
(getKey() == null ? ((HashMap) o).getKey() == null
: getKey().equals(((HashMap) o).getKey())) &&
(getValue() == null ? ((HashMap) o).getValue() == null
: getValue().equals(((HashMap) o).getValue()))</pre>
* this must be:<br>
* <pre>(o instanceof Map.Entry)
* && (getKey() == null ? ((HashMap) o).getKey() == null
* : getKey().equals(((HashMap) o).getKey()))
* && (getValue() == null ? ((HashMap) o).getValue() == null
* : getValue().equals(((HashMap) o).getValue()))</pre>
*
* @param o the object to compare
*
* @return <code>true</code> if it is equal
*/
public final boolean equals(Object o)
......@@ -605,10 +609,9 @@ public abstract class AbstractMap implements Map
/**
* Returns the hash code of the entry. This is defined as the exclusive-or
* of the hashcodes of the key and value (using 0 for null). In other
* words, this must be:
*
<pre>(getKey() == null ? 0 : getKey().hashCode())
^ (getValue() == null ? 0 : getValue().hashCode())</pre>
* words, this must be:<br>
* <pre>(getKey() == null ? 0 : getKey().hashCode())
* ^ (getValue() == null ? 0 : getValue().hashCode())</pre>
*
* @return the hash code
*/
......
......@@ -180,6 +180,15 @@ public class HashMap extends AbstractMap
}
/**
* Called when this entry is accessed via {@link #put(Object, Object)}.
* This version does nothing, but in LinkedHashMap, it must do some
* bookkeeping for access-traversal mode.
*/
void access()
{
}
/**
* Called when this entry is removed from the map. This version simply
* returns the value, but in LinkedHashMap, it must also do bookkeeping.
*
......@@ -338,8 +347,12 @@ public class HashMap extends AbstractMap
while (e != null)
{
if (equals(key, e.key))
// Must use this method for necessary bookkeeping in LinkedHashMap.
return e.setValue(value);
{
e.access(); // Must call this for bookkeeping in LinkedHashMap.
Object r = e.value;
e.value = value;
return r;
}
else
e = e.next;
}
......@@ -368,8 +381,8 @@ public class HashMap extends AbstractMap
public void putAll(Map m)
{
Iterator itr = m.entrySet().iterator();
for (int msize = m.size(); msize > 0; msize--)
int msize = m.size();
while (msize-- > 0)
{
Map.Entry e = (Map.Entry) itr.next();
// Optimize in case the Entry is one of our own.
......@@ -379,9 +392,7 @@ public class HashMap extends AbstractMap
put(entry.key, entry.value);
}
else
{
put(e.getKey(), e.getValue());
}
put(e.getKey(), e.getValue());
}
}
......@@ -520,7 +531,7 @@ public class HashMap extends AbstractMap
public boolean remove(Object o)
{
// Test against the size of the HashMap to determine if anything
// really got removed. This is neccessary because the return value
// really got removed. This is necessary because the return value
// of HashMap.remove() is ambiguous in the null case.
int oldsize = size;
HashMap.this.remove(o);
......@@ -634,7 +645,6 @@ public class HashMap extends AbstractMap
void addEntry(Object key, Object value, int idx, boolean callRemove)
{
HashEntry e = new HashEntry(key, value);
e.next = buckets[idx];
buckets[idx] = e;
}
......@@ -648,17 +658,18 @@ public class HashMap extends AbstractMap
* @see #entrySet()
*/
// Package visible, for use in nested classes.
HashEntry getEntry(Object o)
final HashEntry getEntry(Object o)
{
if (!(o instanceof Map.Entry))
if (! (o instanceof Map.Entry))
return null;
Map.Entry me = (Map.Entry) o;
int idx = hash(me.getKey());
Object key = me.getKey();
int idx = hash(key);
HashEntry e = buckets[idx];
while (e != null)
{
if (e.equals(me))
return e;
if (equals(e.key, key))
return equals(e.value, me.getValue()) ? e : null;
e = e.next;
}
return null;
......@@ -699,9 +710,8 @@ public class HashMap extends AbstractMap
{
Iterator itr = m.entrySet().iterator();
int msize = m.size();
this.size = msize;
for (; msize > 0; msize--)
size = msize;
while (msize-- > 0)
{
Map.Entry e = (Map.Entry) itr.next();
Object key = e.getKey();
......@@ -742,9 +752,7 @@ public class HashMap extends AbstractMap
dest.next = e;
}
else
{
buckets[idx] = e;
}
buckets[idx] = e;
HashEntry next = e.next;
e.next = null;
......@@ -797,13 +805,14 @@ public class HashMap extends AbstractMap
// Read the threshold and loadFactor fields.
s.defaultReadObject();
// Read and use capacity.
// Read and use capacity, followed by key/value pairs.
buckets = new HashEntry[s.readInt()];
int len = s.readInt();
// Read and use key/value pairs.
for ( ; len > 0; len--)
put(s.readObject(), s.readObject());
while (len-- > 0)
{
Object key = s.readObject();
addEntry(key, s.readObject(), hash(key), false);
}
}
/**
......
......@@ -51,7 +51,7 @@ import java.util.Arrays;
public class BinaryRefAddr extends RefAddr
{
static final long serialVersionUID = -3415254970957330361L;
/**
* The possibly null content of this RefAddr.
* Set by the constructor and returned by getContent.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment