summaryrefslogtreecommitdiffstats
path: root/logic/java
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-05-04 01:20:48 +0200
committerPetr Mrázek <peterix@gmail.com>2015-05-04 01:20:48 +0200
commit1b884d0a9dc28d8bca38fe8756482d991d0ea850 (patch)
treefabe4350a3d64123ad0801fe7c285c2150f9562b /logic/java
parent8e9d5f56b592fd0dd0f54e747a835391a775120d (diff)
downloadMultiMC-1b884d0a9dc28d8bca38fe8756482d991d0ea850.tar
MultiMC-1b884d0a9dc28d8bca38fe8756482d991d0ea850.tar.gz
MultiMC-1b884d0a9dc28d8bca38fe8756482d991d0ea850.tar.lz
MultiMC-1b884d0a9dc28d8bca38fe8756482d991d0ea850.tar.xz
MultiMC-1b884d0a9dc28d8bca38fe8756482d991d0ea850.zip
GH-907 improve Java testing and PermGen deprecation handling
Diffstat (limited to 'logic/java')
-rw-r--r--logic/java/JavaChecker.cpp69
-rw-r--r--logic/java/JavaChecker.h13
-rw-r--r--logic/java/JavaVersionList.cpp4
3 files changed, 65 insertions, 21 deletions
diff --git a/logic/java/JavaChecker.cpp b/logic/java/JavaChecker.cpp
index b62ddfbe..18877898 100644
--- a/logic/java/JavaChecker.cpp
+++ b/logic/java/JavaChecker.cpp
@@ -1,5 +1,6 @@
#include "JavaChecker.h"
#include <pathutils.h>
+#include <cmdutils.h>
#include <QFile>
#include <QProcess>
#include <QMap>
@@ -15,26 +16,59 @@ void JavaChecker::performCheck()
{
QString checkerJar = PathCombine(QCoreApplication::applicationDirPath(), "jars", "JavaCheck.jar");
- QStringList args = {"-jar", checkerJar};
+ QStringList args;
process.reset(new QProcess());
+ if(m_args.size())
+ {
+ auto extraArgs = Util::Commandline::splitArgs(m_args);
+ args.append(extraArgs);
+ }
+ if(m_minMem != 0)
+ {
+ args << QString("-Xms%1m").arg(m_minMem);
+ }
+ if(m_maxMem != 0)
+ {
+ args << QString("-Xmx%1m").arg(m_maxMem);
+ }
+ if(m_permGen != 64)
+ {
+ args << QString("-XX:PermSize=%1m").arg(m_permGen);
+ }
+
+ args.append({"-jar", checkerJar});
process->setArguments(args);
- process->setProgram(path);
+ process->setProgram(m_path);
process->setProcessChannelMode(QProcess::SeparateChannels);
- qDebug() << "Running java checker!";
- qDebug() << "Java: " + path;
- qDebug() << "Args: {" + args.join("|") + "}";
-
- connect(process.get(), SIGNAL(finished(int, QProcess::ExitStatus)), this,
- SLOT(finished(int, QProcess::ExitStatus)));
- connect(process.get(), SIGNAL(error(QProcess::ProcessError)), this,
- SLOT(error(QProcess::ProcessError)));
+ qDebug() << "Running java checker: " + m_path + args.join(" ");;
+
+ connect(process.get(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
+ connect(process.get(), SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
+ connect(process.get(), SIGNAL(readyReadStandardOutput()), this, SLOT(stdoutReady()));
+ connect(process.get(), SIGNAL(readyReadStandardError()), this, SLOT(stderrReady()));
connect(&killTimer, SIGNAL(timeout()), SLOT(timeout()));
killTimer.setSingleShot(true);
killTimer.start(15000);
process->start();
}
+void JavaChecker::stdoutReady()
+{
+ QByteArray data = process->readAllStandardOutput();
+ QString added = QString::fromLocal8Bit(data);
+ added.remove('\r');
+ m_stdout += added;
+}
+
+void JavaChecker::stderrReady()
+{
+ QByteArray data = process->readAllStandardError();
+ QString added = QString::fromLocal8Bit(data);
+ added.remove('\r');
+ m_stderr += added;
+}
+
void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
{
killTimer.stop();
@@ -43,9 +77,12 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
JavaCheckResult result;
{
- result.path = path;
- result.id = id;
+ result.path = m_path;
+ result.id = m_id;
}
+ result.stderr = m_stderr;
+ qDebug() << "STDOUT" << m_stdout;
+ qWarning() << "STDERR" << m_stderr;
qDebug() << "Java checker finished with status " << status << " exit code " << exitcode;
if (status == QProcess::CrashExit || exitcode == 1)
@@ -56,11 +93,9 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
}
bool success = true;
- QString p_stdout = _process->readAllStandardOutput();
- qDebug() << p_stdout;
QMap<QString, QString> results;
- QStringList lines = p_stdout.split("\n", QString::SkipEmptyParts);
+ QStringList lines = m_stdout.split("\n", QString::SkipEmptyParts);
for(QString line : lines)
{
line = line.trimmed();
@@ -105,8 +140,8 @@ void JavaChecker::error(QProcess::ProcessError err)
qDebug() << "Java checker has failed to start.";
JavaCheckResult result;
{
- result.path = path;
- result.id = id;
+ result.path = m_path;
+ result.id = m_id;
}
emit checkFinished(result);
diff --git a/logic/java/JavaChecker.h b/logic/java/JavaChecker.h
index e19895f7..29598aa4 100644
--- a/logic/java/JavaChecker.h
+++ b/logic/java/JavaChecker.h
@@ -12,6 +12,7 @@ struct JavaCheckResult
QString mojangPlatform;
QString realPlatform;
QString javaVersion;
+ QString stderr;
bool valid = false;
bool is_64bit = false;
int id;
@@ -26,17 +27,25 @@ public:
explicit JavaChecker(QObject *parent = 0);
void performCheck();
- QString path;
- int id;
+ QString m_path;
+ QString m_args;
+ int m_id = 0;
+ int m_minMem = 0;
+ int m_maxMem = 0;
+ int m_permGen = 64;
signals:
void checkFinished(JavaCheckResult result);
private:
QProcessPtr process;
QTimer killTimer;
+ QString m_stdout;
+ QString m_stderr;
public
slots:
void timeout();
void finished(int exitcode, QProcess::ExitStatus);
void error(QProcess::ProcessError);
+ void stdoutReady();
+ void stderrReady();
};
diff --git a/logic/java/JavaVersionList.cpp b/logic/java/JavaVersionList.cpp
index 7889853b..52f2e62f 100644
--- a/logic/java/JavaVersionList.cpp
+++ b/logic/java/JavaVersionList.cpp
@@ -171,8 +171,8 @@ void JavaListLoadTask::executeTask()
qDebug() << " " << candidate;
auto candidate_checker = new JavaChecker();
- candidate_checker->path = candidate;
- candidate_checker->id = id;
+ candidate_checker->m_path = candidate;
+ candidate_checker->m_id = id;
m_job->addJavaCheckerAction(JavaCheckerPtr(candidate_checker));
id++;