void (Path importFile, Path currentFile, Logger log) { try { var cs = VMOptions.getFileCharset(); var importLines = Files.readAllLines(importFile, cs); var currentLines = Files.readAllLines(currentFile, cs); var result = new ArrayList<String>(importLines.size() + currentLines.size()); var preferCurrentXmx = false; nextLine: for (var line : importLines) { if (line.startsWith("-D")) { var p = line.indexOf('='); if (p > 0) { var prefix = line.substring(0, p + 1); for (var l : currentLines) { if (l.startsWith(prefix)) { continue nextLine; } } } } else if (line.startsWith("-Xmx") && isLowerValue("-Xmx", line.substring(4), currentLines)) { preferCurrentXmx = true; continue nextLine; } result.add(line); } for (var line : currentLines) { if (preferCurrentXmx || !line.startsWith("-Xmx")) { result.add(line); } } Files.write(currentFile, result, cs); } catch (IOException e) { log.warn("Failed to merge VM option files " + importFile + " and " + currentFile, e); } }