diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-09-13 06:36:25 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-09-13 06:36:25 +0000 |
commit | 09c0169650a06161c322d8ad64756aaf3acae40a (patch) | |
tree | d1ce9437fa18890703cab6233079cd8bcce1b50d | |
parent | 7002e559d8a63723667d25988d1aafe1d900d0d0 (diff) | |
download | gcc-09c0169650a06161c322d8ad64756aaf3acae40a.tar.gz |
2000-09-13 Bryce McKinlay <bryce@albatross.co.nz>
* java/lang/String.java (CASE_INSENSITIVE_ORDER): New static field.
Initialize with anonymous class.
(compareToIgnoreCase): New method.
* java/lang/ThreadGroup.java (had_uncaught_exception): New field.
(uncaughtException): Set had_uncaught_exception.
* prims.cc (JvRunMain): Check value of had_uncaught_exception and
exit with error status if set.
(_Jv_RunMain): Ditto.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36385 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libjava/ChangeLog | 12 | ||||
-rw-r--r-- | libjava/java/lang/String.java | 17 | ||||
-rw-r--r-- | libjava/java/lang/ThreadGroup.java | 8 | ||||
-rw-r--r-- | libjava/prims.cc | 10 |
4 files changed, 42 insertions, 5 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 4b7e06b5964..fb5bdd8302e 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,15 @@ +2000-09-13 Bryce McKinlay <bryce@albatross.co.nz> + + * java/lang/String.java (CASE_INSENSITIVE_ORDER): New static field. + Initialize with anonymous class. + (compareToIgnoreCase): New method. + + * java/lang/ThreadGroup.java (had_uncaught_exception): New field. + (uncaughtException): Set had_uncaught_exception. + * prims.cc (JvRunMain): Check value of had_uncaught_exception and + exit with error status if set. + (_Jv_RunMain): Ditto. + 2000-09-12 Alexandre Oliva <aoliva@redhat.com> * configure: Rebuilt with new ../libtool.m4. diff --git a/libjava/java/lang/String.java b/libjava/java/lang/String.java index 9937374f1bc..bc21afd0404 100644 --- a/libjava/java/lang/String.java +++ b/libjava/java/lang/String.java @@ -10,6 +10,7 @@ package java.lang; import java.io.UnsupportedEncodingException; import java.io.Serializable; import java.lang.Comparable; +import java.util.Comparator; /** * @author Per Bothner <bothner@cygnus.com> @@ -17,7 +18,7 @@ import java.lang.Comparable; */ /* Written using "Java Class Libraries", 2nd edition, plus online * API docs for JDK 1.2 beta from http://www.javasoft.com. - * Status: Complete to 1.1, but see FIXMEs. Also see testsuite results. + * Status: Complete to 1.3. */ public final class String implements Serializable, Comparable @@ -30,6 +31,14 @@ public final class String implements Serializable, Comparable // but it will avoid showing up as a discrepancy when comparing SUIDs. private static final long serialVersionUID = -6849794470754667710L; + static Comparator CASE_INSENSITIVE_ORDER = new Comparator() + { + public int compare (Object o1, Object o2) + { + return ((String) o1).compareToIgnoreCase ((String) o2); + } + }; + public String () { init(); @@ -182,6 +191,12 @@ public final class String implements Serializable, Comparable { return compareTo ((String)obj); } + + public int compareToIgnoreCase (String str) + { + return this.toUpperCase().toLowerCase().compareTo( + str.toUpperCase().toLowerCase()); + } public native boolean regionMatches (int toffset, String other, int ooffset, int len); diff --git a/libjava/java/lang/ThreadGroup.java b/libjava/java/lang/ThreadGroup.java index f566e106f17..52c69525098 100644 --- a/libjava/java/lang/ThreadGroup.java +++ b/libjava/java/lang/ThreadGroup.java @@ -53,6 +53,9 @@ public class ThreadGroup { /* The Initial, top-level ThreadGroup. */ static ThreadGroup root = new ThreadGroup(); + /* This flag is set if an uncaught exception occurs. The runtime should + check this and exit with an error status if it is set. */ + static boolean had_uncaught_exception = false; private ThreadGroup parent; private String name; @@ -496,7 +499,10 @@ public class ThreadGroup if (parent != null) parent.uncaughtException (thread, t); else if (! (t instanceof ThreadDeath)) - t.printStackTrace(); + { + t.printStackTrace(); + had_uncaught_exception = true; + } } /** Tell the VM whether it may suspend Threads in low memory diff --git a/libjava/prims.cc b/libjava/prims.cc index 7766f66cec7..92e449645df 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -888,7 +888,9 @@ JvRunMain (jclass klass, int argc, const char **argv) main_thread->start(); _Jv_ThreadWait (); - java::lang::Runtime::getRuntime ()->exit (0); + int status = (int) java::lang::ThreadGroup::had_uncaught_exception; + + java::lang::Runtime::getRuntime ()->exit (status); } void @@ -939,8 +941,10 @@ _Jv_RunMain (const char *name, int argc, const char **argv, bool is_jar) main_thread->start(); _Jv_ThreadWait (); } - - java::lang::Runtime::getRuntime ()->exit (0); + + int status = (int) java::lang::ThreadGroup::had_uncaught_exception; + + java::lang::Runtime::getRuntime ()->exit (status); } |