diff options
Diffstat (limited to 'src/main/java/net/minecraft/server/CrashReport.java')
-rw-r--r-- | src/main/java/net/minecraft/server/CrashReport.java | 151 |
1 files changed, 104 insertions, 47 deletions
diff --git a/src/main/java/net/minecraft/server/CrashReport.java b/src/main/java/net/minecraft/server/CrashReport.java index b5da924c..9b50bb2f 100644 --- a/src/main/java/net/minecraft/server/CrashReport.java +++ b/src/main/java/net/minecraft/server/CrashReport.java @@ -6,11 +6,10 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; +import java.util.List; import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.logging.Logger; @@ -19,40 +18,29 @@ public class CrashReport { private final String a; private final Throwable b; - private final Map c = new LinkedHashMap(); - private File d = null; + private final CrashReportSystemDetails c = new CrashReportSystemDetails(this, "System Details"); + private final List d = new ArrayList(); + private File e = null; + private boolean f = true; + private StackTraceElement[] g = new StackTraceElement[0]; public CrashReport(String s, Throwable throwable) { this.a = s; this.b = throwable; - this.g(); + this.h(); } - private void g() { - this.a("Minecraft Version", (Callable) (new CrashReportVersion(this))); - this.a("Operating System", (Callable) (new CrashReportOperatingSystem(this))); - this.a("Java Version", (Callable) (new CrashReportJavaVersion(this))); - this.a("Java VM Version", (Callable) (new CrashReportJavaVMVersion(this))); - this.a("Memory", (Callable) (new CrashReportMemory(this))); - this.a("JVM Flags", (Callable) (new CrashReportJVMFlags(this))); - this.a("AABB Pool Size", (Callable) (new CrashReportAABBPoolSize(this))); - this.a("CraftBukkit Information", (Callable) (new org.bukkit.craftbukkit.CraftCrashReport())); // CraftBukkit - } - - public void a(String s, Callable callable) { - try { - this.a(s, callable.call()); - } catch (Throwable throwable) { - this.a(s, throwable); - } - } - - public void a(String s, Object object) { - this.c.put(s, object == null ? "null" : object.toString()); - } - - public void a(String s, Throwable throwable) { - this.a(s, ("~ERROR~ " + throwable.getClass().getSimpleName() + ": " + throwable.getMessage())); + private void h() { + this.c.a("Minecraft Version", (Callable) (new CrashReportVersion(this))); + this.c.a("Operating System", (Callable) (new CrashReportOperatingSystem(this))); + this.c.a("Java Version", (Callable) (new CrashReportJavaVersion(this))); + this.c.a("Java VM Version", (Callable) (new CrashReportJavaVMVersion(this))); + this.c.a("Memory", (Callable) (new CrashReportMemory(this))); + this.c.a("JVM Flags", (Callable) (new CrashReportJVMFlags(this))); + this.c.a("AABB Pool Size", (Callable) (new CrashReportAABBPoolSize(this))); + this.c.a("Suspicious classes", (Callable) (new CrashReportSuspiciousClasses(this))); + this.c.a("IntCache", (Callable) (new CrashReportIntCacheSize(this))); + this.c.a("CraftBukkit Information", (Callable) (new org.bukkit.craftbukkit.CraftCrashReport())); // CraftBukkit } public String a() { @@ -64,20 +52,32 @@ public class CrashReport { } public void a(StringBuilder stringbuilder) { - boolean flag = true; + if (this.g != null && this.g.length > 0) { + stringbuilder.append("-- Head --\n"); + stringbuilder.append("Stacktrace:\n"); + StackTraceElement[] astacktraceelement = this.g; + int i = astacktraceelement.length; - for (Iterator iterator = this.c.entrySet().iterator(); iterator.hasNext(); flag = false) { - Entry entry = (Entry) iterator.next(); + for (int j = 0; j < i; ++j) { + StackTraceElement stacktraceelement = astacktraceelement[j]; - if (!flag) { + stringbuilder.append("\t").append("at ").append(stacktraceelement.toString()); stringbuilder.append("\n"); } - stringbuilder.append("- "); - stringbuilder.append((String) entry.getKey()); - stringbuilder.append(": "); - stringbuilder.append((String) entry.getValue()); + stringbuilder.append("\n"); } + + Iterator iterator = this.d.iterator(); + + while (iterator.hasNext()) { + CrashReportSystemDetails crashreportsystemdetails = (CrashReportSystemDetails) iterator.next(); + + crashreportsystemdetails.a(stringbuilder); + stringbuilder.append("\n\n"); + } + + this.c.a(stringbuilder); } public String d() { @@ -112,7 +112,7 @@ public class CrashReport { stringbuilder.append("---- Minecraft Crash Report ----\n"); stringbuilder.append("// "); - stringbuilder.append(h()); + stringbuilder.append(i()); stringbuilder.append("\n\n"); stringbuilder.append("Time: "); stringbuilder.append((new SimpleDateFormat()).format(new Date())); @@ -121,15 +121,19 @@ public class CrashReport { stringbuilder.append(this.a); stringbuilder.append("\n\n"); stringbuilder.append(this.d()); - stringbuilder.append("\n"); - stringbuilder.append("Relevant Details:"); - stringbuilder.append("\n"); + stringbuilder.append("\n\nA detailed walkthrough of the error, its code path and all known details is as follows:\n"); + + for (int i = 0; i < 87; ++i) { + stringbuilder.append("-"); + } + + stringbuilder.append("\n\n"); this.a(stringbuilder); return stringbuilder.toString(); } public boolean a(File file1) { - if (this.d != null) { + if (this.e != null) { return false; } else { if (file1.getParentFile() != null) { @@ -141,7 +145,7 @@ public class CrashReport { filewriter.write(this.e()); filewriter.close(); - this.d = file1; + this.e = file1; return true; } catch (Throwable throwable) { Logger.getLogger("Minecraft").log(Level.SEVERE, "Could not save crash report to " + file1, throwable); @@ -150,8 +154,49 @@ public class CrashReport { } } - private static String h() { - String[] astring = new String[] { "Who set us up the TNT?", "Everything\'s going to plan. No, really, that was supposed to happen.", "Uh... Did I do that?", "Oops.", "Why did you do that?", "I feel sad now :(", "My bad.", "I\'m sorry, Dave.", "I let you down. Sorry :(", "On the bright side, I bought you a teddy bear!", "Daisy, daisy...", "Oh - I know what I did wrong!", "Hey, that tickles! Hehehe!", "I blame Dinnerbone.", "You should try our sister game, Minceraft!", "Don\'t be sad. I\'ll do better next time, I promise!", "Don\'t be sad, have a hug! <3", "I just don\'t know what went wrong :(", "Shall we play a game?", "Quite honestly, I wouldn\'t worry myself about that.", "I bet Cylons wouldn\'t have this problem.", "Sorry :(", "Surprise! Haha. Well, this is awkward.", "Would you like a cupcake?", "Hi. I\'m Minecraft, and I\'m a crashaholic.", "Ooh. Shiny.", "This doesn\'t make any sense!", "Why is it breaking :("}; + public CrashReportSystemDetails g() { + return this.c; + } + + public CrashReportSystemDetails a(String s) { + return this.a(s, 1); + } + + public CrashReportSystemDetails a(String s, int i) { + CrashReportSystemDetails crashreportsystemdetails = new CrashReportSystemDetails(this, s); + + if (this.f) { + int j = crashreportsystemdetails.a(i); + StackTraceElement[] astacktraceelement = this.b.getStackTrace(); + StackTraceElement stacktraceelement = null; + StackTraceElement stacktraceelement1 = null; + + if (astacktraceelement != null && astacktraceelement.length - j < astacktraceelement.length) { + stacktraceelement = astacktraceelement[astacktraceelement.length - j]; + if (astacktraceelement.length + 1 - j < astacktraceelement.length) { + stacktraceelement1 = astacktraceelement[astacktraceelement.length + 1 - j]; + } + } + + this.f = crashreportsystemdetails.a(stacktraceelement, stacktraceelement1); + if (j > 0 && !this.d.isEmpty()) { + CrashReportSystemDetails crashreportsystemdetails1 = (CrashReportSystemDetails) this.d.get(this.d.size() - 1); + + crashreportsystemdetails1.b(j); + } else if (astacktraceelement != null && astacktraceelement.length >= j) { + this.g = new StackTraceElement[astacktraceelement.length - j]; + System.arraycopy(astacktraceelement, 0, this.g, 0, this.g.length); + } else { + this.f = false; + } + } + + this.d.add(crashreportsystemdetails); + return crashreportsystemdetails; + } + + private static String i() { + String[] astring = new String[] { "Who set us up the TNT?", "Everything\'s going to plan. No, really, that was supposed to happen.", "Uh... Did I do that?", "Oops.", "Why did you do that?", "I feel sad now :(", "My bad.", "I\'m sorry, Dave.", "I let you down. Sorry :(", "On the bright side, I bought you a teddy bear!", "Daisy, daisy...", "Oh - I know what I did wrong!", "Hey, that tickles! Hehehe!", "I blame Dinnerbone.", "You should try our sister game, Minceraft!", "Don\'t be sad. I\'ll do better next time, I promise!", "Don\'t be sad, have a hug! <3", "I just don\'t know what went wrong :(", "Shall we play a game?", "Quite honestly, I wouldn\'t worry myself about that.", "I bet Cylons wouldn\'t have this problem.", "Sorry :(", "Surprise! Haha. Well, this is awkward.", "Would you like a cupcake?", "Hi. I\'m Minecraft, and I\'m a crashaholic.", "Ooh. Shiny.", "This doesn\'t make any sense!", "Why is it breaking :(", "Don\'t do that.", "Ouch. That hurt :(", "You\'re mean.", "This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]", "There are four lights!"}; try { return astring[(int) (System.nanoTime() % (long) astring.length)]; @@ -159,4 +204,16 @@ public class CrashReport { return "Witty comment unavailable :("; } } + + public static CrashReport a(Throwable throwable, String s) { + CrashReport crashreport; + + if (throwable instanceof ReportedException) { + crashreport = ((ReportedException) throwable).a(); + } else { + crashreport = new CrashReport(s, throwable); + } + + return crashreport; + } } |