[Nice-commit] Nice/src/nice/tools/util source-lines.nice,1.2,1.3
Brought to you by:
bonniot
From: <ar...@us...> - 2004-02-04 06:00:21
|
Update of /cvsroot/nice/Nice/src/nice/tools/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21084/F:/nice/src/nice/tools/util Modified Files: source-lines.nice Log Message: Use reflection in printStackTraceWithSourceInfo. Index: source-lines.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/util/source-lines.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** source-lines.nice 3 Feb 2004 01:45:51 -0000 1.2 --- source-lines.nice 3 Feb 2004 16:08:19 -0000 1.3 *************** *** 20,23 **** --- 20,24 ---- import java.io.*; + import nice.lang.reflect; public void printStackTraceWithSourceInfo(Throwable t) = *************** *** 27,44 **** printStackTraceWithSourceInfo(t, new PrintWriter(s)); public void printStackTraceWithSourceInfo(Throwable t, PrintWriter w) { w.println("Exception in thread \"" Thread.currentThread().getName "\" " t); try { ! let elements = t.getStackTrace(); ! elements.foreach(StackTraceElement e => { (?String file, int line) = ! getSourceLocation(e.getClassName(), e.getLineNumber()) ! || (e.getFileName(), e.getLineNumber()); let location = ! file == null ? (e.isNativeMethod ? "Native Method" : "Unknown Source") : line < 0 ? file : (file + ":" + line); ! w.println("\tat " e.getClassName "." e.getMethodName "(" location ")"); }); } catch (NoSuchMethodError e) { --- 28,52 ---- printStackTraceWithSourceInfo(t, new PrintWriter(s)); + String STE_getClassName(Object ste) = ste.call("getClassName"); + ?String STE_getFileName(Object ste) = ste.call("getFileName"); + String STE_getMethodName(Object ste) = ste.call("getMethodName"); + int STE_getLineNumber(Object ste) = ste.call("getLineNumber"); + boolean STE_isNativeMethod(Object ste) = ste.call("isNativeMethod"); + public void printStackTraceWithSourceInfo(Throwable t, PrintWriter w) { w.println("Exception in thread \"" Thread.currentThread().getName "\" " t); try { ! let getSTMethod = t.getClass().getMethod("getStackTrace", null); ! let Object[] elements = cast(getSTMethod.invoke(t, null)); ! elements.foreach(Object e => { (?String file, int line) = ! getSourceLocation(e.STE_getClassName(), e.STE_getLineNumber()) ! || (e.STE_getFileName(), e.STE_getLineNumber()); let location = ! file == null ? (e.STE_isNativeMethod ? "Native Method" : "Unknown Source") : line < 0 ? file : (file + ":" + line); ! w.println("\tat " e.STE_getClassName "." e.STE_getMethodName "(" location ")"); }); } catch (NoSuchMethodError e) { |