Permalink
Browse files

Backport #267 and #269 to master, closes #262

  • Loading branch information...
1 parent c4b6237 commit 9ccbde7ce645ac912b7f9e628d6cf853f837c7de @dgelessus dgelessus committed Aug 25, 2016
View
@@ -15,3 +15,6 @@
!/README.md
!/STYLE.md
!/TESTING.md
+
+# OS X things
+.DS_Store
@@ -512,7 +512,7 @@ public static void integrate() {
Properties props = new Properties();
props.load(new FileInputStream(f));
- props.setProperty("java_version", Utils.getJavaVersion());
+ props.setProperty("java_version", Utils.getLauncherJavaVersion());
props.setProperty("location", App.settings.getBaseDir().toString());
props.setProperty("executable", new File(Update.class.getProtectionDomain().getCodeSource().getLocation()
.getPath()).getAbsolutePath());
@@ -18,19 +18,20 @@
package com.atlauncher;
+import java.io.CharArrayWriter;
+import java.io.PrintWriter;
+
public final class ExceptionStrainer implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
-
- if (e.getMessage() != null && !e.getMessage().isEmpty()) {
- LogManager.error(e.getMessage());
- }
-
- for (StackTraceElement element : e.getStackTrace()) {
- if (element != null) {
- LogManager.error(element.toString());
- }
+
+ CharArrayWriter writer = new CharArrayWriter();
+ try {
+ e.printStackTrace(new PrintWriter(writer));
+ LogManager.error(writer.toString());
+ } finally {
+ writer.close();
}
}
}
@@ -54,6 +54,7 @@
import java.awt.event.WindowAdapter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
+import java.io.CharArrayWriter;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
@@ -66,6 +67,7 @@
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.net.Proxy;
@@ -2611,33 +2613,29 @@ public String getLog() {
/**
* Logs a stack trace to the console window
*
- * @param exception The exception to show in the console
+ * @param t The throwable to show in the console
*/
- public void logStackTrace(Exception exception) {
- exception.printStackTrace();
-
- if (exception.getMessage() != null) {
- LogManager.error(exception.getMessage());
- }
-
- if (exception.getStackTrace() != null) {
- for (StackTraceElement element : exception.getStackTrace()) {
- if (element != null) {
- LogManager.error(element.toString());
- }
- }
+ public void logStackTrace(Throwable t) {
+ t.printStackTrace();
+
+ CharArrayWriter writer = new CharArrayWriter();
+ try {
+ t.printStackTrace(new PrintWriter(writer));
+ LogManager.error(writer.toString());
+ } finally {
+ writer.close();
}
}
/**
* Logs a stack trace to the console window with a custom message before it
*
* @param message A message regarding the stack trace to show before it providing more insight
- * @param exception The exception to show in the console
+ * @param t The throwable to show in the console
*/
- public void logStackTrace(String message, Exception exception) {
+ public void logStackTrace(String message, Throwable t) {
LogManager.error(message);
- logStackTrace(exception);
+ logStackTrace(t);
}
public void showKillMinecraft(Process minecraft) {
@@ -128,13 +128,13 @@ public static Process launch(Account account, Instance instance, LoginResponse s
arguments.add("-Xmx" + App.settings.getMaximumMemory() + "M");
}
if (App.settings.getPermGen() < instance.getPermGen() && (Utils.getMaximumRam() / 8) < instance.getPermGen()) {
- if (Utils.isJava8()) {
+ if (Utils.useMetaspace()) {
arguments.add("-XX:MetaspaceSize=" + instance.getPermGen() + "M");
} else {
arguments.add("-XX:PermSize=" + instance.getPermGen() + "M");
}
} else {
- if (Utils.isJava8()) {
+ if (Utils.useMetaspace()) {
arguments.add("-XX:MetaspaceSize=" + App.settings.getPermGen() + "M");
} else {
arguments.add("-XX:PermSize=" + App.settings.getPermGen() + "M");
@@ -131,13 +131,13 @@ public static Process launch(Account account, Instance instance, LoginResponse r
arguments.add("-Xmx" + App.settings.getMaximumMemory() + "M");
}
if (App.settings.getPermGen() < instance.getPermGen() && (Utils.getMaximumRam() / 8) < instance.getPermGen()) {
- if (Utils.isJava8() || Utils.isJava9()) {
+ if (Utils.useMetaspace()) {
arguments.add("-XX:MetaspaceSize=" + instance.getPermGen() + "M");
} else {
arguments.add("-XX:PermSize=" + instance.getPermGen() + "M");
}
} else {
- if (Utils.isJava8() || Utils.isJava9()) {
+ if (Utils.useMetaspace()) {
arguments.add("-XX:MetaspaceSize=" + App.settings.getPermGen() + "M");
} else {
arguments.add("-XX:PermSize=" + App.settings.getPermGen() + "M");
Oops, something went wrong.

0 comments on commit 9ccbde7

Please sign in to comment.