diff options
Diffstat (limited to 'libjava/gnu')
-rw-r--r-- | libjava/gnu/gcj/runtime/NameFinder.java | 75 | ||||
-rw-r--r-- | libjava/gnu/java/lang/MainThread.java | 4 |
2 files changed, 53 insertions, 26 deletions
diff --git a/libjava/gnu/gcj/runtime/NameFinder.java b/libjava/gnu/gcj/runtime/NameFinder.java index 024a6ee..b14bbf9 100644 --- a/libjava/gnu/gcj/runtime/NameFinder.java +++ b/libjava/gnu/gcj/runtime/NameFinder.java @@ -37,8 +37,8 @@ import java.io.File; * Whether calls to unknown functions (class and method names are unknown) * should be removed from the stack trace. Only done when the stack is * sanitized.</ul> - * <ul><code>gnu.gcj.runtime.NameFinder.remove_interpreter</code> - * Whether runtime interpreter calls (methods in the _Jv_InterpMethod class + * <ul><code>gnu.gcj.runtime.NameFinder.remove_internal</code> + * Whether runtime internal calls (methods in the internal _Jv_* classes * and functions starting with 'ffi_') should be removed from the stack * trace. Only done when the stack is sanitized.</ul> * <ul><code>gnu.gcj.runtime.NameFinder.use_addr2line</code> @@ -72,10 +72,18 @@ public class NameFinder = Boolean.valueOf(System.getProperty ("gnu.gcj.runtime.NameFinder.remove_unknown", "true") ).booleanValue(); - private static final boolean remove_interpreter - = Boolean.valueOf(System.getProperty + + // The remove_interpreter name is an old 3.3/3.4 (deprecated) synonym. + private static final boolean remove_internal + = (Boolean.valueOf(System.getProperty + ("gnu.gcj.runtime.NameFinder.remove_internal", "true") + ).booleanValue() + || + Boolean.valueOf(System.getProperty ("gnu.gcj.runtime.NameFinder.remove_interpreter", "true") - ).booleanValue(); + ).booleanValue() + ); + private static final boolean use_addr2line = Boolean.valueOf(System.getProperty ("gnu.gcj.runtime.NameFinder.use_addr2line", "true") @@ -280,7 +288,7 @@ public class NameFinder consName = className.substring(lastDot + 1) + '('; int unknown = 0; - int interpreter = 0; + int internal = 0; int last_throw = -1; int length = elements.length; int end = length-1; @@ -300,19 +308,23 @@ public class NameFinder || MName.startsWith("fillInStackTrace(")))) { last_throw = i; - // Reset counting of unknown and interpreter frames. + // Reset counting of unknown and internal frames. unknown = 0; - interpreter = 0; + internal = 0; } else if (remove_unknown && CName == null && (MName == null || MName.startsWith("0x"))) unknown++; - else if (remove_interpreter + else if (remove_internal && ((CName == null && MName != null && MName.startsWith("ffi_")) - || (CName != null && CName.equals("_Jv_InterpMethod")))) - interpreter++; - else if ("main(java.lang.String[])".equals(MName)) + || (CName != null && CName.startsWith("_Jv_")) + || (CName == null && MName != null + && MName.startsWith("_Jv_")))) + internal++; + else if (("java.lang.Thread".equals(CName) + || "gnu.java.lang.MainThread".equals(CName)) + && "run()".equals(MName)) { end = i; break; @@ -321,11 +333,11 @@ public class NameFinder int begin = last_throw+1; // Now filter out everything at the start and the end that is not part - // of the "normal" user program including any elements that are interpreter + // of the "normal" user program including any elements that are internal // calls or have no usefull information whatsoever. // Unless that means we filter out all info. - int nr_elements = end-begin-unknown-interpreter+1; - if ((begin > 0 || end < length-1 || unknown > 0 || interpreter > 0) + int nr_elements = end - begin - unknown - internal + 1; + if ((begin > 0 || end < length-1 || unknown > 0 || internal > 0) && nr_elements > 0) { stack = new StackTraceElement[nr_elements]; @@ -337,14 +349,27 @@ public class NameFinder if (remove_unknown && CName == null && (MName == null || MName.startsWith("0x"))) ; // Skip unknown frame - else if (remove_interpreter + else if (remove_internal && ((CName == null - && MName != null && MName.startsWith("ffi_")) - || (CName != null && CName.equals("_Jv_InterpMethod")))) - ; // Skip interpreter runtime frame + && MName != null && MName.startsWith("ffi_")) + || (CName != null && CName.startsWith("_Jv_")) + || (CName == null && MName != null + && MName.startsWith("_Jv_")))) + ; // Skip internal runtime frame else { - stack[pos] = elements[i]; + // Null Class or Method name in elements are not allowed. + if (MName == null || CName == null) + { + MName = MName == null ? "" : MName; + CName = CName == null ? "" : CName; + stack[pos] = newElement(elements[i].getFileName(), + elements[i].getLineNumber(), + CName, MName, + elements[i].isNativeMethod()); + } + else + stack[pos] = elements[i]; pos++; } } @@ -359,11 +384,11 @@ public class NameFinder * Native helper method to create a StackTraceElement. Needed to work * around normal Java access restrictions. */ - native private StackTraceElement newElement(String fileName, - int lineNumber, - String className, - String methName, - boolean isNative); + native static private StackTraceElement newElement(String fileName, + int lineNumber, + String className, + String methName, + boolean isNative); /** * Creates a StackTraceElement given a string and a filename. diff --git a/libjava/gnu/java/lang/MainThread.java b/libjava/gnu/java/lang/MainThread.java index 5937b87..14a00ca 100644 --- a/libjava/gnu/java/lang/MainThread.java +++ b/libjava/gnu/java/lang/MainThread.java @@ -95,7 +95,9 @@ final class MainThread extends Thread } catch (ClassNotFoundException x) { - throw new NoClassDefFoundError(klass_name); + NoClassDefFoundError ncdfe = new NoClassDefFoundError(klass_name); + ncdfe.initCause(x); + throw ncdfe; } } |