Commit 4fbecd29 by Bryce McKinlay Committed by Bryce McKinlay

Merge JDK 1.4 exception chaining support from classpath.

	* java/lang/Throwable.java: Merge 1.4 support from classpath.
	(stackTraceBytes): Rename from stackTrace.
	* java/lang/Exception.java: Merge from classpath.
	* java/lang/StackTraceElement: New file from classpath.
	* gcj/javaprims.h: Rebuild CNI namespace declarations.
	* Makefile.am: Add StackTraceElement.
	* Makefile.in: Rebuilt.

From-SVN: r53836
parent 7efda054
2002-05-24 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
Merge JDK 1.4 exception chaining support from classpath.
* java/lang/Throwable.java: Merge 1.4 support from classpath.
(stackTraceBytes): Rename from stackTrace.
* java/lang/Exception.java: Merge from classpath.
* java/lang/StackTraceElement: New file from classpath.
* gcj/javaprims.h: Rebuild CNI namespace declarations.
* Makefile.am: Add StackTraceElement.
* Makefile.in: Rebuilt.
2002-05-23 Bryce McKinlay <bryce@waitaki.otago.ac.nz> 2002-05-23 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* Makefile.am (all-recursive): Depend on $all_java_class_files so that * Makefile.am (all-recursive): Depend on $all_java_class_files so that
......
...@@ -1084,6 +1084,7 @@ java/lang/SecurityException.java \ ...@@ -1084,6 +1084,7 @@ java/lang/SecurityException.java \
java/lang/SecurityManager.java \ java/lang/SecurityManager.java \
java/lang/Short.java \ java/lang/Short.java \
java/lang/StackOverflowError.java \ java/lang/StackOverflowError.java \
java/lang/StackTraceElement.java \
java/lang/StrictMath.java \ java/lang/StrictMath.java \
java/lang/String.java \ java/lang/String.java \
java/lang/StringBuffer.java \ java/lang/StringBuffer.java \
...@@ -1418,7 +1419,7 @@ gnu/java/security/provider/SHA1PRNG.java \ ...@@ -1418,7 +1419,7 @@ gnu/java/security/provider/SHA1PRNG.java \
gnu/java/text/BaseBreakIterator.java \ gnu/java/text/BaseBreakIterator.java \
gnu/java/text/CharacterBreakIterator.java \ gnu/java/text/CharacterBreakIterator.java \
gnu/java/text/LineBreakIterator.java \ gnu/java/text/LineBreakIterator.java \
gnu/java/text/SentenceBreakIterator.java \ gnu/java/text/SentenceBreakIterator.java \
gnu/java/text/WordBreakIterator.java \ gnu/java/text/WordBreakIterator.java \
gnu/java/util/DoubleEnumeration.java \ gnu/java/util/DoubleEnumeration.java \
java/lang/ref/PhantomReference.java \ java/lang/ref/PhantomReference.java \
......
...@@ -851,6 +851,7 @@ java/lang/SecurityException.java \ ...@@ -851,6 +851,7 @@ java/lang/SecurityException.java \
java/lang/SecurityManager.java \ java/lang/SecurityManager.java \
java/lang/Short.java \ java/lang/Short.java \
java/lang/StackOverflowError.java \ java/lang/StackOverflowError.java \
java/lang/StackTraceElement.java \
java/lang/StrictMath.java \ java/lang/StrictMath.java \
java/lang/String.java \ java/lang/String.java \
java/lang/StringBuffer.java \ java/lang/StringBuffer.java \
...@@ -1180,7 +1181,7 @@ gnu/java/security/provider/SHA1PRNG.java \ ...@@ -1180,7 +1181,7 @@ gnu/java/security/provider/SHA1PRNG.java \
gnu/java/text/BaseBreakIterator.java \ gnu/java/text/BaseBreakIterator.java \
gnu/java/text/CharacterBreakIterator.java \ gnu/java/text/CharacterBreakIterator.java \
gnu/java/text/LineBreakIterator.java \ gnu/java/text/LineBreakIterator.java \
gnu/java/text/SentenceBreakIterator.java \ gnu/java/text/SentenceBreakIterator.java \
gnu/java/text/WordBreakIterator.java \ gnu/java/text/WordBreakIterator.java \
gnu/java/util/DoubleEnumeration.java \ gnu/java/util/DoubleEnumeration.java \
java/lang/ref/PhantomReference.java \ java/lang/ref/PhantomReference.java \
...@@ -2267,7 +2268,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ ...@@ -2267,7 +2268,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/lang/Runtime.P .deps/java/lang/RuntimeException.P \ .deps/java/lang/Runtime.P .deps/java/lang/RuntimeException.P \
.deps/java/lang/RuntimePermission.P .deps/java/lang/SecurityException.P \ .deps/java/lang/RuntimePermission.P .deps/java/lang/SecurityException.P \
.deps/java/lang/SecurityManager.P .deps/java/lang/Short.P \ .deps/java/lang/SecurityManager.P .deps/java/lang/Short.P \
.deps/java/lang/StackOverflowError.P .deps/java/lang/StrictMath.P \ .deps/java/lang/StackOverflowError.P \
.deps/java/lang/StackTraceElement.P .deps/java/lang/StrictMath.P \
.deps/java/lang/String.P .deps/java/lang/StringBuffer.P \ .deps/java/lang/String.P .deps/java/lang/StringBuffer.P \
.deps/java/lang/StringIndexOutOfBoundsException.P \ .deps/java/lang/StringIndexOutOfBoundsException.P \
.deps/java/lang/System.P .deps/java/lang/Thread.P \ .deps/java/lang/System.P .deps/java/lang/Thread.P \
......
...@@ -193,6 +193,7 @@ extern "Java" ...@@ -193,6 +193,7 @@ extern "Java"
class SecurityManager; class SecurityManager;
class Short; class Short;
class StackOverflowError; class StackOverflowError;
class StackTraceElement;
class StrictMath; class StrictMath;
class String; class String;
class String$CaseInsensitiveComparator; class String$CaseInsensitiveComparator;
...@@ -241,32 +242,43 @@ extern "Java" ...@@ -241,32 +242,43 @@ extern "Java"
{ {
class AbstractCollection; class AbstractCollection;
class AbstractList; class AbstractList;
class AbstractList$AbstractListItr;
class AbstractMap; class AbstractMap;
class AbstractSequentialList; class AbstractSequentialList;
class AbstractSet; class AbstractSet;
class ArrayList; class ArrayList;
class Arrays; class Arrays;
class Arrays$ArrayList;
class Arrays$ListImpl; class Arrays$ListImpl;
class BasicMapEntry; class BasicMapEntry;
class BitSet; class BitSet;
class Calendar; class Calendar;
class Collection; class Collection;
class Collections; class Collections;
class Collections$CopiesList;
class Collections$EmptyList;
class Collections$EmptyMap;
class Collections$EmptySet;
class Collections$ReverseComparator; class Collections$ReverseComparator;
class Collections$SingletonList;
class Collections$SingletonMap;
class Collections$SingletonSet;
class Collections$SynchronizedCollection; class Collections$SynchronizedCollection;
class Collections$SynchronizedIterator; class Collections$SynchronizedIterator;
class Collections$SynchronizedList; class Collections$SynchronizedList;
class Collections$SynchronizedListIterator; class Collections$SynchronizedListIterator;
class Collections$SynchronizedMap; class Collections$SynchronizedMap;
class Collections$SynchronizedMapEntry;
class Collections$SynchronizedRandomAccessList;
class Collections$SynchronizedSet; class Collections$SynchronizedSet;
class Collections$SynchronizedSortedMap; class Collections$SynchronizedSortedMap;
class Collections$SynchronizedSortedSet; class Collections$SynchronizedSortedSet;
class Collections$UnmodifiableCollection; class Collections$UnmodifiableCollection;
class Collections$UnmodifiableEntrySet;
class Collections$UnmodifiableIterator; class Collections$UnmodifiableIterator;
class Collections$UnmodifiableList; class Collections$UnmodifiableList;
class Collections$UnmodifiableListIterator; class Collections$UnmodifiableListIterator;
class Collections$UnmodifiableMap; class Collections$UnmodifiableMap;
class Collections$UnmodifiableRandomAccessList;
class Collections$UnmodifiableSet; class Collections$UnmodifiableSet;
class Collections$UnmodifiableSortedMap; class Collections$UnmodifiableSortedMap;
class Collections$UnmodifiableSortedSet; class Collections$UnmodifiableSortedSet;
...@@ -288,10 +300,12 @@ extern "Java" ...@@ -288,10 +300,12 @@ extern "Java"
class Hashtable$HashEntry; class Hashtable$HashEntry;
class Hashtable$HashIterator; class Hashtable$HashIterator;
class IdentityHashMap; class IdentityHashMap;
class IdentityHashMap$IdentityEntry;
class IdentityHashMap$IdentityIterator; class IdentityHashMap$IdentityIterator;
class Iterator; class Iterator;
class LinkedHashMap; class LinkedHashMap;
class LinkedHashMap$LinkedHashEntry; class LinkedHashMap$LinkedHashEntry;
class LinkedHashSet;
class LinkedList; class LinkedList;
class LinkedList$Entry; class LinkedList$Entry;
class LinkedList$LinkedListItr; class LinkedList$LinkedListItr;
...@@ -311,7 +325,9 @@ extern "Java" ...@@ -311,7 +325,9 @@ extern "Java"
class PropertyResourceBundle; class PropertyResourceBundle;
class Random; class Random;
class RandomAccess; class RandomAccess;
class RandomAccessSubList;
class ResourceBundle; class ResourceBundle;
class ResourceBundle$Security;
class Set; class Set;
class SimpleTimeZone; class SimpleTimeZone;
class SortedMap; class SortedMap;
...@@ -329,12 +345,11 @@ extern "Java" ...@@ -329,12 +345,11 @@ extern "Java"
class TreeMap$Node; class TreeMap$Node;
class TreeMap$SubMap; class TreeMap$SubMap;
class TreeMap$TreeIterator; class TreeMap$TreeIterator;
class TreeMap$VerifyResult;
class TreeSet; class TreeSet;
class Vector; class Vector;
class WeakHashMap; class WeakHashMap;
class WeakHashMap$Entry;
class WeakHashMap$WeakBucket; class WeakHashMap$WeakBucket;
class WeakHashMap$WeakEntry;
class WeakHashMap$WeakEntrySet; class WeakHashMap$WeakEntrySet;
namespace jar namespace jar
{ {
...@@ -372,7 +387,7 @@ extern "Java" ...@@ -372,7 +387,7 @@ extern "Java"
class ZipOutputStream; class ZipOutputStream;
}; };
}; };
}; };
}; };
typedef struct java::lang::Object* jobject; typedef struct java::lang::Object* jobject;
......
/* Exception.java -- generic exception thrown to indicate an exceptional /* Exception.java -- generic exception thrown to indicate an exceptional
condition has occurred. condition has occurred.
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -8,7 +8,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -8,7 +8,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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -39,40 +39,66 @@ exception statement from your version. */ ...@@ -39,40 +39,66 @@ exception statement from your version. */
package java.lang; 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 * The root class of all exceptions worth catching in a program. This
* by another in order to deal with the cause of the exception, such as * includes the special category of <code>RuntimeException</code>, which
* does not need to be declared in a throws clause. Exceptions can be used
* to represent almost any exceptional behavior, such as programming errors,
* mouse movements, keyboard clicking, etc. * mouse movements, keyboard clicking, etc.
* *
* @since JDK 1.0
*
* @author Brian Jones * @author Brian Jones
* @author Warren Levy <warrenl@cygnus.com> * @author Warren Levy <warrenl@cygnus.com>
* @date September 18, 1998. * @author Eric Blake <ebb9@email.byu.edu>
* @status updated to 1.4
*/ */
public class Exception extends Throwable public class Exception extends Throwable
{ {
static final long serialVersionUID = -3387516993124229948L; /**
* Compatible with JDK 1.0+.
*/
private static final long serialVersionUID = -3387516993124229948L;
/** /**
* Create an exception without a message. * Create an exception without a message. The cause remains uninitialized.
*
* @see #initCause(Throwable)
*/ */
public Exception() public Exception()
{ {
super(); }
}
/** /**
* Create an exception with a message. * Create an exception with a message. The cause remains uninitialized.
*
* @param s the message
* @see #initCause(Throwable)
*/ */
public Exception(String s) public Exception(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 error
* @since 1.4
*/
public Exception(String s, Throwable cause)
{
super(s, cause);
}
/**
* Create an exception with a given cause, and a message of
* <code>cause == null ? null : cause.toString()</code>.
*
* @param cause the cause of this exception
* @since 1.4
*/
public Exception(Throwable cause)
{
super(cause);
}
} }
/* StackTraceElement.java -- One function call or call stack element
Copyright (C) 2001, 2002 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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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.lang;
import java.io.Serializable;
/**
* One function call or stack trace element. Gives information about
* the execution point such as the source file name, the line number,
* the fully qualified class name, the method name and whether this method
* is native, if this information is known.
*
* @author Mark Wielaard <mark@klomp.org>
* @author Eric Blake <ebb9@email.byu.edu>
* @since 1.4
* @status updated to 1.4
*/
public class StackTraceElement implements Serializable
{
/**
* Compatible with JDK 1.4+.
*/
private static final long serialVersionUID = 6992337162326171013L;
/**
* The name of the file, null if unknown.
*
* @serial the source code filename, if known
*/
private final String fileName;
/**
* The line number in the file, negative if unknown.
*
* @serial the source code line number, if known
*/
private final int lineNumber;
/**
* The fully qualified class name, null if unknown.
*
* @serial the enclosing class, if known
*/
private final String className;
/**
* The method name in the class, null if unknown.
*
* @serial the enclosing method, if known
*/
private final String methodName;
/** Whether the method is native. */
private final transient boolean isNative;
/**
* A package local constructor for the StackTraceElement class, to be
* called by the Virtual Machine as part of Throwable.fillInStackTrace.
* There are no public constructors defined for this class. Creation
* of new elements is implementation specific.
*
* @param fileName the name of the file, null if unknown
* @param lineNumber the line in the file, negative if unknown
* @param className the fully qualified name of the class, null if unknown
* @param methodName the name of the method, null if unknown
* @param isNative true if native, false otherwise
*/
StackTraceElement(String fileName, int lineNumber, String className,
String methodName, boolean isNative)
{
this.fileName = fileName;
this.lineNumber = lineNumber;
this.className = className;
this.methodName = methodName;
this.isNative = isNative;
}
/**
* Returns the name of the file, or null if unknown. This is usually
* obtained from the <code>SourceFile</code> attribute of the class file
* format, if present.
*
* @return the file name
*/
public String getFileName()
{
return fileName;
}
/**
* Returns the line number in the file, or a negative number if unknown.
* This is usually obtained from the <code>LineNumberTable</code> attribute
* of the method in the class file format, if present.
*
* @return the line number
*/
public int getLineNumber()
{
return lineNumber;
}
/**
* Returns the fully qualified class name, or null if unknown.
*
* @return the class name
*/
public String getClassName()
{
return className;
}
/**
* Returns the method name in the class, or null if unknown. If the
* execution point is in a constructor, the name is
* <code>&lt;init&gt;</code>; if the execution point is in the class
* initializer, the name is <code>&lt;clinit&gt;</code>.
*
* @return the method name
*/
public String getMethodName()
{
return methodName;
}
/**
* Returns true if the method is native, or false if it is not or unknown.
*
* @return whether the method is native
*/
public boolean isNativeMethod()
{
return isNative;
}
/**
* Returns a string representation of this stack trace element. The
* returned String is implementation specific. This implementation
* returns the following String: "[class][.][method]([file][:line])".
* If the fully qualified class name or the method is unknown it is
* omitted including the point seperator. If the source file name is
* unknown it is replaced by "Unknown Source" if the method is not native
* or by "Native Method" if the method is native. If the line number
* is unknown it and the colon are omitted.
*
* @return a string representation of this execution point
*/
public String toString()
{
StringBuffer sb = new StringBuffer();
if (className != null)
{
sb.append(className);
if (methodName != null)
sb.append('.');
}
if (methodName != null)
sb.append(methodName);
sb.append('(');
if (fileName != null)
sb.append(fileName);
else
sb.append(isNative ? "Native Method" : "Unknown Source");
if (lineNumber >= 0)
sb.append(':').append(lineNumber);
sb.append(')');
return sb.toString();
}
/**
* Returns true if the given object is also a StackTraceElement and all
* attributes, except the native flag, are equal (either the same attribute
* between the two elments are null, or both satisfy Object.equals).
*
* @param o the object to compare
* @return true if the two are equal
*/
public boolean equals(Object o)
{
if (! (o instanceof StackTraceElement))
return false;
StackTraceElement e = (StackTraceElement) o;
return equals(fileName, e.fileName)
&& lineNumber == e.lineNumber
&& equals(className, e.className)
&& equals(methodName, e.methodName);
}
/**
* Returns the hashCode of this StackTraceElement. This implementation
* computes the hashcode by xor-ing the hashcode of all attributes except
* the native flag.
*
* @return the hashcode
*/
public int hashCode()
{
return hashCode(fileName) ^ lineNumber ^ hashCode(className)
^ hashCode(methodName);
}
/**
* Compare two objects according to Collection semantics.
*
* @param o1 the first object
* @param o2 the second object
* @return o1 == null ? o2 == null : o1.equals(o2)
*/
private static final boolean equals(Object o1, Object o2)
{
return o1 == null ? o2 == null : o1.equals(o2);
}
/**
* Hash an object according to Collection semantics.
*
* @param o the object to hash
* @return o1 == null ? 0 : o1.hashCode()
*/
private static final int hashCode(Object o)
{
return o == null ? 0 : o.hashCode();
}
}
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