void (Path newConfigDir, Logger log) { Path vmOptionsFile = newConfigDir.resolve(VMOptions.getFileName()); if (Files.exists(vmOptionsFile)) { try { List<String> lines = Files.readAllLines(vmOptionsFile, VMOptions.getFileCharset()); Path platformVmOptionsFile = newConfigDir.getFileSystem().getPath(VMOptions.getPlatformOptionsFile().toString()); Collection<String> platformLines = new LinkedHashSet<>(readPlatformOptions(platformVmOptionsFile, log)); boolean updated = false; for (ListIterator<String> i = lines.listIterator(); i.hasNext(); ) { String line = i.next().trim(); if (line.equals("-XX:MaxJavaStackTraceDepth=-1")) { i.set("-XX:MaxJavaStackTraceDepth=10000"); updated = true; } else if ("-XX:+UseConcMarkSweepGC".equals(line) || "-Xverify:none".equals(line) || "-noverify".equals(line) || "-XX:+UseCompressedOops".equals(line) || line.startsWith("-agentlib:yjpagent") || line.startsWith("-agentpath:") && line.contains("yjpagent") || "-Dsun.io.useCanonPrefixCache=false".equals(line) || "-Dfile.encoding=UTF-8".equals(line) && SystemInfoRt.isMac || isDuplicateOrLowerValue(line, platformLines)) { i.remove(); updated = true; } } if (updated) { Files.write(vmOptionsFile, lines, VMOptions.getFileCharset()); } } catch (IOException e) { log.warn("Failed to update custom VM options file " + vmOptionsFile, e); } } }