MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / checkJVMArgs

Method checkJVMArgs

launcher/JavaCommon.cpp:42–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40#include <QRegularExpression>
41
42bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
43{
44 if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegularExpression("-Xm[sx]"))
45 || jvmargs.contains("-XX-MaxHeapSize") || jvmargs.contains("-XX:InitialHeapSize"))
46 {
47 auto warnStr = QObject::tr(
48 "You tried to manually set a JVM memory option (using \"-XX:PermSize\", \"-XX-MaxHeapSize\", \"-XX:InitialHeapSize\", \"-Xmx\" or \"-Xms\").\n"
49 "There are dedicated boxes for these in the settings (Java tab, in the Memory group at the top).\n"
50 "This message will be displayed until you remove them from the JVM arguments.");
51 CustomMessageBox::selectable(
52 parent, QObject::tr("JVM arguments warning"),
53 warnStr,
54 QMessageBox::Warning)->exec();
55 return false;
56 }
57 // block lunacy with passing required version to the JVM
58 if (jvmargs.contains(QRegularExpression("-version:.*"))) {
59 auto warnStr = QObject::tr(
60 "You tried to pass required Java version argument to the JVM (using \"-version:xxx\"). This is not safe and will not be allowed.\n"
61 "This message will be displayed until you remove this from the JVM arguments.");
62 CustomMessageBox::selectable(
63 parent, QObject::tr("JVM arguments warning"),
64 warnStr,
65 QMessageBox::Warning)->exec();
66 return false;
67 }
68 return true;
69}
70
71void JavaCommon::javaWasOk(QWidget *parent, JavaCheckResult result)
72{

Callers

nothing calls this directly

Calls 3

selectableFunction · 0.85
containsMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected