From 548ce8be4ab154b7d7f42ae8fe8552f9888021d0 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 16 Jun 2002 21:15:44 +0000 Subject: [PATCH] RuntimeException.java: Re-merge with Classpath. * java/lang/RuntimeException.java: Re-merge with Classpath. * java/util/ArrayList.java: Likewise. * java/util/Arrays.java: Likewise. * java/util/BitSet.java: Likewise. * java/util/Dictionary.java: Likewise. * java/util/IdentityHashMap.java: Likewise. * java/util/MissingResourceException.java: Likewise. * java/util/Observer.java: Likewise. * java/util/TooManyListenersException.java: Likewise. * java/util/zip/DataFormatException.java: Likewise. * java/util/zip/ZipException.java: Likewise. From-SVN: r54680 --- libjava/ChangeLog | 14 ++++ libjava/java/lang/RuntimeException.java | 69 ++++++++++++------- libjava/java/util/ArrayList.java | 2 +- libjava/java/util/Arrays.java | 8 +-- libjava/java/util/BitSet.java | 35 +++++----- libjava/java/util/Dictionary.java | 13 ++-- libjava/java/util/IdentityHashMap.java | 47 +++++++------ .../java/util/MissingResourceException.java | 38 +++++----- libjava/java/util/Observer.java | 23 ++++--- .../java/util/TooManyListenersException.java | 24 +++---- .../java/util/zip/DataFormatException.java | 29 +++++--- libjava/java/util/zip/ZipException.java | 30 +++++--- 12 files changed, 202 insertions(+), 130 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index f27fe76ccc4..0e39f29b028 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,17 @@ +2002-06-16 Tom Tromey + + * java/lang/RuntimeException.java: Re-merge with Classpath. + * java/util/ArrayList.java: Likewise. + * java/util/Arrays.java: Likewise. + * java/util/BitSet.java: Likewise. + * java/util/Dictionary.java: Likewise. + * java/util/IdentityHashMap.java: Likewise. + * java/util/MissingResourceException.java: Likewise. + * java/util/Observer.java: Likewise. + * java/util/TooManyListenersException.java: Likewise. + * java/util/zip/DataFormatException.java: Likewise. + * java/util/zip/ZipException.java: Likewise. + 2002-06-16 Nathanael Nerode * java/rmi/AccessException.java: Remerge from Classpath. diff --git a/libjava/java/lang/RuntimeException.java b/libjava/java/lang/RuntimeException.java index 616a05e3dd8..8fc9fb10aab 100644 --- a/libjava/java/lang/RuntimeException.java +++ b/libjava/java/lang/RuntimeException.java @@ -1,6 +1,5 @@ -/* RuntimeException.java -- all exceptions which are subclasses of this class - can be thrown at any time during the execution of a Java virtual machine. - Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. +/* RuntimeException.java -- root of all unchecked exceptions + Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -8,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -39,43 +38,65 @@ exception statement from your version. */ package java.lang; -/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 - * "The Java Language Specification", ISBN 0-201-63451-1 - * plus online API docs for JDK 1.2 beta from http://www.javasoft.com. - * Status: Believed complete and correct. - */ - /** - * Exceptions may be thrown by one part of a Java program and caught - * by another in order to deal with exceptional conditions. * All exceptions which are subclasses of RuntimeException * can be thrown at any time during the execution of a Java virtual machine. * Methods which throw these exceptions are not required to declare them * in their throws clause. * - * @since JDK 1.0 - * * @author Brian Jones * @author Warren Levy - * @date September 18, 1998. + * @author Eric Blake + * @status updated to 1.4 */ public class RuntimeException extends Exception { - static final long serialVersionUID = -7034897190745766939L; + /** + * Compatible with JDK 1.0+. + */ + private static final long serialVersionUID = -7034897190745766939L; /** - * Create an exception without a message. + * Create an exception without a message. The cause remains uninitialized. + * + * @see #initCause(Throwable) */ public RuntimeException() - { - super(); - } + { + } /** - * Create an exception with a message. + * Create an exception with a message. The cause remains uninitialized. + * + * @param s the message string + * @see #initCause(Throwable) */ public RuntimeException(String s) - { - super(s); - } + { + super(s); + } + + /** + * Create an exception with a message and a cause. + * + * @param s the message string + * @param cause the cause of this exception + * @since 1.4 + */ + public RuntimeException(String s, Throwable cause) + { + super(s, cause); + } + + /** + * Create an exception with the given cause, and a message of + * cause == null ? null : cause.toString(). + * + * @param cause the cause of this exception + * @since 1.4 + */ + public RuntimeException(Throwable cause) + { + super(cause); + } } diff --git a/libjava/java/util/ArrayList.java b/libjava/java/util/ArrayList.java index 99745d0f648..2d2146ddf59 100644 --- a/libjava/java/util/ArrayList.java +++ b/libjava/java/util/ArrayList.java @@ -160,7 +160,7 @@ public class ArrayList extends AbstractList /** * Guarantees that this list will have at least enough capacity to * hold minCapacity elements. This implementation will grow the list to - * max(current * 2, minCapacity) if (minCapacity > current). The JCL says + * max(current * 2, minCapacity) if (minCapacity > current). The JCL says * explictly that "this method increases its capacity to minCap", while * the JDK 1.3 online docs specify that the list will grow to at least the * size specified. diff --git a/libjava/java/util/Arrays.java b/libjava/java/util/Arrays.java index 8126cf26410..35e0e92ca59 100644 --- a/libjava/java/util/Arrays.java +++ b/libjava/java/util/Arrays.java @@ -2205,9 +2205,9 @@ public class Arrays * comparable * @throws NullPointerException if an element is null (since * null.compareTo cannot work) - * @throws ArrayIndexOutOfBoundsException, if fromIndex and toIndex + * @throws ArrayIndexOutOfBoundsException if fromIndex and toIndex * are not in range. - * @throws IllegalArgumentException if fromIndex > toIndex + * @throws IllegalArgumentException if fromIndex > toIndex */ public static void sort(Object[] a, int fromIndex, int toIndex) { @@ -2229,9 +2229,9 @@ public class Arrays * the elements' natural order * @throws ClassCastException if any two elements are not mutually * comparable by the Comparator provided - * @throws ArrayIndexOutOfBoundsException, if fromIndex and toIndex + * @throws ArrayIndexOutOfBoundsException if fromIndex and toIndex * are not in range. - * @throws IllegalArgumentException if fromIndex > toIndex + * @throws IllegalArgumentException if fromIndex > toIndex * @throws NullPointerException if a null element is compared with natural * ordering (only possible when c is null) */ diff --git a/libjava/java/util/BitSet.java b/libjava/java/util/BitSet.java index 38a9be08994..c56c0d18c7f 100644 --- a/libjava/java/util/BitSet.java +++ b/libjava/java/util/BitSet.java @@ -398,22 +398,24 @@ public class BitSet implements Cloneable, Serializable * bit k is set in the BitSet (for non-negative values * of k) if and only if * - *
-   * ((k/64) < bits.length) && ((bits[k/64] & (1L << (bit % 64))) != 0)
-   * 
+ * ((k/64) < bits.length) + * && ((bits[k/64] & (1L << (bit % 64))) != 0) + * * * Then the following definition of the hashCode method * would be a correct implementation of the actual algorithm: * - *
-   * public int hashCode() {
-   *     long h = 1234;
-   *     for (int i = bits.length-1; i>=0; i--) {
-   *         h ^= bits[i] * (i + 1);
-   *     }
-   *     return (int)((h >> 32) ^ h);
-   * }
-   * 
+ * +
public int hashCode()
+{
+  long h = 1234;
+  for (int i = bits.length-1; i >= 0; i--)
+  {
+    h ^= bits[i] * (i + 1);
+  }
+
+  return (int)((h >> 32) ^ h);
+}
* * Note that the hash code values changes, if the set is changed. * @@ -526,10 +528,11 @@ public class BitSet implements Cloneable, Serializable * Returns the index of the next true bit, from the specified bit * (inclusive). If there is none, -1 is returned. You can iterate over * all true bits with this loop:
- *
-   * for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1))
-   *   { // operate on i here }
-   * 
+ * +
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1))
+{
+  // operate on i here
+}
* * @param from the start location * @return the first true bit, or -1 diff --git a/libjava/java/util/Dictionary.java b/libjava/java/util/Dictionary.java index 401e45a39c7..53c4d640836 100644 --- a/libjava/java/util/Dictionary.java +++ b/libjava/java/util/Dictionary.java @@ -1,6 +1,6 @@ /* Dictionary.java -- an abstract (and essentially worthless) class which is Hashtable's superclass - Copyright (C) 1998, 2001 Free Software Foundation, Inc. + Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,18 +47,21 @@ package java.util; * People at Javasoft are probably embarrassed by it. At this point, * it might as well be an interface rather than a class, but it remains * this poor, laughable skeleton for the sake of backwards compatibility. - * At any rate, this was what came before the
Map
interface + * At any rate, this was what came before the {@link Map} interface * in the Collections framework. * * @author Jon Zeppieri - * @author Eric Blake + * @author Eric Blake (ebb9@email.byu.edu) * @see Map * @see Hashtable * @since 1.0 * @status updated to 1.4 */ -public abstract class Dictionary extends Object +public abstract class Dictionary { + // WARNING: Dictionary is a CORE class in the bootstrap cycle. See the + // comments in vm/reference/java/lang/Runtime for implications of this fact. + /** * Sole constructor (often called implicitly). */ @@ -130,4 +133,4 @@ public abstract class Dictionary extends Object * @return the number of keys in the Dictionary */ public abstract int size(); -} +} // class Dictionary diff --git a/libjava/java/util/IdentityHashMap.java b/libjava/java/util/IdentityHashMap.java index 4609f015f8d..f48c430cf9a 100644 --- a/libjava/java/util/IdentityHashMap.java +++ b/libjava/java/util/IdentityHashMap.java @@ -162,9 +162,9 @@ public class IdentityHashMap extends AbstractMap // Need at least two slots, or hash() will break. if (max < 2) max = 2; - table = new Object[2 * max]; + table = new Object[max << 1]; Arrays.fill(table, emptyslot); - threshold = max / 4 * 3; + threshold = (max >> 2) * 3; } /** @@ -176,7 +176,7 @@ public class IdentityHashMap extends AbstractMap */ public IdentityHashMap(Map m) { - this(Math.max(m.size() * 2, DEFAULT_CAPACITY)); + this(Math.max(m.size() << 1, DEFAULT_CAPACITY)); putAll(m); } @@ -341,12 +341,14 @@ public class IdentityHashMap extends AbstractMap } /** - * Return the value in this Map associated with the supplied key, - * or
null
if the key maps to nothing. NOTE: Since the value - * could also be null, you must use containsKey to see if this key - * actually maps to something. Unlike normal maps, this tests for the key - * with entry == key instead of - * entry == null ? key == null : entry.equals(key). + * Return the value in this Map associated with the supplied key, or + * null if the key maps to nothing. + * + *

NOTE: Since the value could also be null, you must use + * containsKey to see if this key actually maps to something. + * Unlike normal maps, this tests for the key with entry == + * key instead of entry == null ? key == null : + * entry.equals(key). * * @param key the key for which to fetch an associated value * @return what the key maps to, if present @@ -487,10 +489,10 @@ public class IdentityHashMap extends AbstractMap Object[] old = table; // This isn't necessarily prime, but it is an odd number of key/value // slots, which has a higher probability of fewer collisions. - table = new Object[old.length * 2 + 2]; + table = new Object[old.length << 1 + 2]; Arrays.fill(table, emptyslot); size = 0; - threshold = (table.length / 2) / 4 * 3; + threshold = (table.length >>> 3) * 3; for (int i = old.length - 2; i >= 0; i -= 2) { @@ -531,13 +533,15 @@ public class IdentityHashMap extends AbstractMap } /** - * Removes from the HashMap and returns the value which is mapped by the - * supplied key. If the key maps to nothing, then the HashMap remains - * unchanged, and

null
is returned. NOTE: Since the value - * could also be null, you must use containsKey to see if you are - * actually removing a mapping. Unlike normal maps, this tests for the - * key with entry == key instead of - * entry == null ? key == null : entry.equals(key). + * Removes from the HashMap and returns the value which is mapped by + * the supplied key. If the key maps to nothing, then the HashMap + * remains unchanged, and null is returned. + * + * NOTE: Since the value could also be null, you must use + * containsKey to see if you are actually removing a mapping. + * Unlike normal maps, this tests for the key with entry == + * key instead of entry == null ? key == null : + * entry.equals(key). * * @param key the key used to locate the value to remove * @return whatever the key mapped to, if present @@ -642,7 +646,7 @@ public class IdentityHashMap extends AbstractMap // By requiring at least 2 key/value slots, and rehashing at 75% // capacity, we guarantee that there will always be either an emptyslot // or a tombstone somewhere in the table. - int h = 2 * Math.abs(System.identityHashCode(key) % (table.length / 2)); + int h = Math.abs(System.identityHashCode(key) % (table.length >> 1)) << 1; int del = -1; int save = h; @@ -735,7 +739,8 @@ public class IdentityHashMap extends AbstractMap /** * Removes from the backing Map the last element which was fetched - * with the
next()
method. + * with the next() method. + * * @throws ConcurrentModificationException if the Map was modified * @throws IllegalStateException if called when there is no last element */ @@ -894,7 +899,7 @@ public class IdentityHashMap extends AbstractMap s.defaultReadObject(); int num = s.readInt(); - table = new Object[2 * Math.max(num * 2, DEFAULT_CAPACITY)]; + table = new Object[Math.max(num << 1, DEFAULT_CAPACITY) << 1]; // Read key/value pairs. while (--num >= 0) put(s.readObject(), s.readObject()); diff --git a/libjava/java/util/MissingResourceException.java b/libjava/java/util/MissingResourceException.java index 1618c4f56ab..47525e55bfa 100644 --- a/libjava/java/util/MissingResourceException.java +++ b/libjava/java/util/MissingResourceException.java @@ -1,5 +1,5 @@ -/* java.util.MissingResourceException - Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. +/* MissingResourceException.java -- thrown for a missing resource + Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,38 +38,42 @@ exception statement from your version. */ package java.util; -/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 - * "The Java Language Specification", ISBN 0-201-63451-1 - * plus online API docs for JDK 1.2 beta from http://www.javasoft.com. - * Status: Believed complete and correct. - */ - /** * This exception is thrown when a resource is missing. * - * @see ResourceBundle * @author Jochen Hoenicke * @author Warren Levy + * @see ResourceBundle + * @since 1.1 + * @status updated to 1.4 */ public class MissingResourceException extends RuntimeException { + /** + * Compatible with JDK 1.1+. + */ private static final long serialVersionUID = -4876345176062000401L; /** * The name of the resource bundle requested by user. + * + * @serial the class name of the resource bundle */ - private String className; + private final String className; /** * The key of the resource in the bundle requested by user. + * + * @serial the name of the resouce */ - private String key; + private final String key; /** * Creates a new exception, with the specified parameters. - * @param s the detail message. - * @param className the name of the resource bundle. - * @param key the key of the missing resource. + * + * @param s the detail message + * @param className the name of the resource bundle + * @param key the key of the missing resource */ public MissingResourceException(String s, String className, String key) { @@ -80,7 +84,8 @@ public class MissingResourceException extends RuntimeException /** * Gets the name of the resource bundle, for which a resource is missing. - * @return the name of the resource bundle. + * + * @return the name of the resource bundle */ public String getClassName() { @@ -90,7 +95,8 @@ public class MissingResourceException extends RuntimeException /** * Gets the key of the resource that is missing bundle, this is an empty * string if the whole resource bundle is missing. - * @return the name of the resource bundle. + * + * @return the name of the resource bundle */ public String getKey() { diff --git a/libjava/java/util/Observer.java b/libjava/java/util/Observer.java index d18170de3a1..a703e90099e 100644 --- a/libjava/java/util/Observer.java +++ b/libjava/java/util/Observer.java @@ -1,6 +1,5 @@ -/* Implemented when a class wants to be informed of changes in Observable - objects. - Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. +/* Observer.java -- an object that will be informed of changes in an Observable + Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,21 +38,23 @@ exception statement from your version. */ package java.util; -/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 - * "The Java Language Specification", ISBN 0-201-63451-1 - * plus online API docs for JDK 1.2 beta from http://www.javasoft.com. - * Status: Believed complete and correct - */ - /** * Interface that is implemented when a class wants to be informed of changes * in Observable objects. * - * @see java.util.Observable * @author Warren Levy - * @date August 25, 1998. + * @see Observable + * @status updated to 1.4 */ public interface Observer { + /** + * This method is called whenever the observable object changes, and has + * called notifyObservers. The Observable object can pass + * arbitrary information in the second parameter. + * + * @param observable the Observable object that changed + * @param arg arbitrary information, usually relating to the change + */ public void update(Observable observable, Object arg); } diff --git a/libjava/java/util/TooManyListenersException.java b/libjava/java/util/TooManyListenersException.java index 803cd784653..883bdbc7086 100644 --- a/libjava/java/util/TooManyListenersException.java +++ b/libjava/java/util/TooManyListenersException.java @@ -1,5 +1,6 @@ -/* java.util.TooManyListenersException - Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. +/* TooManyListenersException.java -- thrown when a unicast event can't accept + another Listener + Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,26 +39,24 @@ exception statement from your version. */ package java.util; -/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 - * "The Java Language Specification", ISBN 0-201-63451-1 - * plus online API docs for JDK 1.2 beta from http://www.javasoft.com. - * Status: Believed complete and correct. - */ - /** * This exception is part of the java event model. It is thrown if an * event listener is added via the addXyzEventListener method, but the * object doesn't support any more listeners, e.g. it only supports a * single event listener. * + * @author Jochen Hoenicke + * @author Warren Levy * @see EventListener * @see EventObject - * @author Jochen Hoenicke - * @author Warren Levy + * @since 1.1 + * @status updated to 1.4 */ - public class TooManyListenersException extends Exception { + /** + * Compatible with JDK 1.1+. + */ private static final long serialVersionUID = 5074640544770687831L; /** @@ -69,7 +68,8 @@ public class TooManyListenersException extends Exception /** * Constructs a TooManyListenersException with a detail message. - * @param detail the detail message. + * + * @param detail the detail message */ public TooManyListenersException(String detail) { diff --git a/libjava/java/util/zip/DataFormatException.java b/libjava/java/util/zip/DataFormatException.java index 28ecef059b7..e5a948e8a29 100644 --- a/libjava/java/util/zip/DataFormatException.java +++ b/libjava/java/util/zip/DataFormatException.java @@ -1,5 +1,5 @@ -/* DataformatException.java - Exception thrown when compressed data is corrupt - Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +/* DataformatException.java -- thrown when compressed data is corrupt + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,25 +37,34 @@ exception statement from your version. */ package java.util.zip; -/* Written using on-line Java Platform 1.2 API Specification. - * Believed complete and correct. - */ - /** * Exception thrown when compressed data is corrupt. * * @author Tom Tromey * @author John Leuner - * @since JDK 1.1 + * @since 1.1 + * @status updated to 1.4 */ public class DataFormatException extends Exception { - public DataFormatException () + /** + * Compatible with JDK 1.1+. + */ + private static final long serialVersionUID = 2219632870893641452L; + + /** + * Create an exception without a message. + */ + public DataFormatException() { - super(); } - public DataFormatException (String msg) + /** + * Create an exception with a message. + * + * @param msg the message + */ + public DataFormatException(String msg) { super(msg); } diff --git a/libjava/java/util/zip/ZipException.java b/libjava/java/util/zip/ZipException.java index ed02c856464..9130ef2967a 100644 --- a/libjava/java/util/zip/ZipException.java +++ b/libjava/java/util/zip/ZipException.java @@ -1,5 +1,5 @@ -/* ZipException.java - Exception representing a zip related error - Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +/* ZipException.java - exception representing a zip related error + Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,24 +37,34 @@ exception statement from your version. */ package java.util.zip; -/* Written using on-line Java Platform 1.2 API Specification. - * Believed complete and correct. - */ +import java.io.IOException; /** - * Is thrown during the creation or input of a zip file. + * Thrown during the creation or input of a zip file. * * @author Jochen Hoenicke * @author Per Bothner - * @since JDK 1.1 + * @status updated to 1.4 */ -public class ZipException extends java.io.IOException +public class ZipException extends IOException { - public ZipException () + /** + * Compatible with JDK 1.0+. + */ + private static final long serialVersionUID = 8000196834066748623L; + + /** + * Create an exception without a message. + */ + public ZipException() { - super(); } + /** + * Create an exception with a message. + * + * @param msg the message + */ public ZipException (String msg) { super(msg); -- 2.30.2