From 167ea2c5d59f29df5d4bc4bdc9eecf32ec2bf42a Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sun, 17 Sep 2017 10:31:58 -0700 Subject: [PATCH] Use some diamond operators just for kicks. --- .../threerings/getdown/data/Application.java | 46 +++++++++---------- .../com/threerings/getdown/data/Digest.java | 8 ++-- .../threerings/getdown/launcher/Getdown.java | 10 ++-- .../getdown/launcher/GetdownApp.java | 4 +- .../getdown/launcher/GetdownApplet.java | 2 +- .../getdown/launcher/GetdownAppletConfig.java | 2 +- .../threerings/getdown/net/Downloader.java | 4 +- .../com/threerings/getdown/tools/Differ.java | 8 ++-- .../threerings/getdown/tools/Digester.java | 2 +- .../com/threerings/getdown/tools/JarDiff.java | 16 +++---- .../getdown/tools/JarDiffPatcher.java | 8 ++-- .../threerings/getdown/util/ConfigUtil.java | 4 +- .../com/threerings/getdown/util/FileUtil.java | 4 +- 13 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/threerings/getdown/data/Application.java b/src/main/java/com/threerings/getdown/data/Application.java index 6ae3ca8..0a725dc 100644 --- a/src/main/java/com/threerings/getdown/data/Application.java +++ b/src/main/java/com/threerings/getdown/data/Application.java @@ -304,7 +304,7 @@ public class Application */ public List getAllActiveResources () { - List allResources = new ArrayList(); + List allResources = new ArrayList<>(); allResources.addAll(getActiveCodeResources()); allResources.addAll(getActiveResources()); return allResources; @@ -350,7 +350,7 @@ public class Application */ public List getActiveCodeResources () { - ArrayList codes = new ArrayList(); + ArrayList codes = new ArrayList<>(); codes.addAll(getCodeResources()); for (AuxGroup aux : getAuxGroups()) { if (isAuxGroupActive(aux.name)) { @@ -365,7 +365,7 @@ public class Application */ public List getActiveResources () { - ArrayList rsrcs = new ArrayList(); + ArrayList rsrcs = new ArrayList<>(); rsrcs.addAll(getResources()); for (AuxGroup aux : getAuxGroups()) { if (isAuxGroupActive(aux.name)) { @@ -529,7 +529,7 @@ public class Application if (cdata == null) { String appbase = SysProps.appBase(); log.info("Attempting to obtain 'appbase' from system property", "appbase", appbase); - cdata = new HashMap(); + cdata = new HashMap<>(); cdata.put("appbase", appbase); } @@ -622,12 +622,12 @@ public class Application // check for tracking progress percent configuration String trackPcts = (String)cdata.get("tracking_percents"); if (!StringUtil.isBlank(trackPcts)) { - _trackingPcts = new HashSet(); + _trackingPcts = new HashSet<>(); for (int pct : StringUtil.parseIntArray(trackPcts)) { _trackingPcts.add(pct); } } else if (!StringUtil.isBlank(_trackingURL)) { - _trackingPcts = new HashSet(); + _trackingPcts = new HashSet<>(); _trackingPcts.add(50); } @@ -663,10 +663,10 @@ public class Application // parse our auxiliary resource groups for (String auxgroup : parseList(cdata, "auxgroups")) { - ArrayList codes = new ArrayList(); + ArrayList codes = new ArrayList<>(); parseResources(cdata, auxgroup + ".code", false, codes); parseResources(cdata, auxgroup + ".ucode", true, codes); - ArrayList rsrcs = new ArrayList(); + ArrayList rsrcs = new ArrayList<>(); parseResources(cdata, auxgroup + ".resource", false, rsrcs); parseResources(cdata, auxgroup + ".uresource", true, rsrcs); _auxgroups.put(auxgroup, new AuxGroup(auxgroup, codes, rsrcs)); @@ -945,7 +945,7 @@ public class Application public Process createProcess (boolean optimum) throws IOException { - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); // reconstruct the path to the JVM args.add(LaunchUtil.getJVMPath(_appdir, _windebug || optimum)); @@ -1033,14 +1033,14 @@ public class Application */ protected String[] createEnvironment () { - List envvar = new ArrayList(); + List envvar = new ArrayList<>(); fillAssignmentListFromPairs("env.txt", envvar); if (envvar.isEmpty()) { log.info("Didn't find any custom environment variables, not setting any."); return null; } - List envAssignments = new ArrayList(); + List envAssignments = new ArrayList<>(); for (String assignment : envvar) { envAssignments.add(processArg(assignment)); } @@ -1087,7 +1087,7 @@ public class Application } // pass along any pass-through arguments - Map passProps = new HashMap(); + Map passProps = new HashMap<>(); for (Map.Entry entry : System.getProperties().entrySet()) { String key = (String)entry.getKey(); if (key.startsWith(PROP_PASSTHROUGH_PREFIX)) { @@ -1317,9 +1317,9 @@ public class Application final boolean noUnpack = SysProps.noUnpack(); final int[] fAlreadyValid = alreadyValid; - final Set toInstallAsync = new ConcurrentSkipListSet(toInstall); - final Set toDownloadAsync = new ConcurrentSkipListSet(); - final Set unpackedAsync = new ConcurrentSkipListSet(); + final Set toInstallAsync = new ConcurrentSkipListSet<>(toInstall); + final Set toDownloadAsync = new ConcurrentSkipListSet<>(); + final Set unpackedAsync = new ConcurrentSkipListSet<>(); for (int ii = 0; ii < sizes.length; ii++) { final Resource rsrc = rsrcs.get(ii); @@ -1717,7 +1717,7 @@ public class Application */ public static List intsToList (int[] values) { - List list = new ArrayList(values.length); + List list = new ArrayList<>(values.length); for (int val : values) { list.add(val); } @@ -1894,24 +1894,24 @@ public class Application protected boolean _javaExactVersionRequired; protected String _javaLocation; - protected List _codes = new ArrayList(); - protected List _resources = new ArrayList(); + protected List _codes = new ArrayList<>(); + protected List _resources = new ArrayList<>(); protected boolean _useCodeCache; protected int _codeCacheRetentionDays; - protected Map _auxgroups = new HashMap(); - protected Map _auxactive = new HashMap(); + protected Map _auxgroups = new HashMap<>(); + protected Map _auxactive = new HashMap<>(); - protected List _jvmargs = new ArrayList(); - protected List _appargs = new ArrayList(); + protected List _jvmargs = new ArrayList<>(); + protected List _appargs = new ArrayList<>(); protected String[] _extraJvmArgs; protected String[] _extraAppArgs; protected String[] _optimumJvmArgs; - protected List _txtJvmArgs = new ArrayList(); + protected List _txtJvmArgs = new ArrayList<>(); protected List _signers; diff --git a/src/main/java/com/threerings/getdown/data/Digest.java b/src/main/java/com/threerings/getdown/data/Digest.java index af9e3cb..9d085eb 100644 --- a/src/main/java/com/threerings/getdown/data/Digest.java +++ b/src/main/java/com/threerings/getdown/data/Digest.java @@ -49,13 +49,13 @@ public class Digest { // first compute the digests for all the resources in parallel Executor exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); - final Map digests = new ConcurrentHashMap(); - final BlockingQueue completed = new LinkedBlockingQueue(); + final Map digests = new ConcurrentHashMap<>(); + final BlockingQueue completed = new LinkedBlockingQueue<>(); final int fversion = version; long start = System.currentTimeMillis(); - Set pending = new HashSet(resources); + Set pending = new HashSet<>(resources); for (final Resource rsrc : resources) { exec.execute(new Runnable() { public void run () { @@ -212,7 +212,7 @@ public class Digest data.append(path).append(" = ").append(digest).append("\n"); } - protected HashMap _digests = new HashMap(); + protected HashMap _digests = new HashMap<>(); protected String _metaDigest = ""; protected static final String FILE_NAME = "digest"; diff --git a/src/main/java/com/threerings/getdown/launcher/Getdown.java b/src/main/java/com/threerings/getdown/launcher/Getdown.java index 87e5844..8999843 100644 --- a/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -430,9 +430,9 @@ public abstract class Getdown extends Thread int[] alreadyValid = new int[1]; // we'll keep track of all the resources we unpack - Set unpacked = new HashSet(); + Set unpacked = new HashSet<>(); - _toInstallResources = new HashSet(); + _toInstallResources = new HashSet<>(); _readyToInstall = false; //setStep(Step.START); @@ -466,7 +466,7 @@ public abstract class Getdown extends Thread // now verify our resources... setStep(Step.VERIFY_RESOURCES); setStatusAsync("m.validating", -1, -1L, false); - Set toDownload = new HashSet(); + Set toDownload = new HashSet<>(); _app.verifyResources(_progobs, alreadyValid, unpacked, _toInstallResources, toDownload); if (toDownload.size() == 0) { @@ -622,7 +622,7 @@ public abstract class Getdown extends Thread reportTrackingEvent("jvm_start", -1); updateStatus("m.downloading_java"); - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(vmjar); download(list); @@ -682,7 +682,7 @@ public abstract class Getdown extends Thread // attempt to download the patch files Resource patch = _app.getPatchResource(null); if (patch != null) { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(patch); // add the auxiliary group patch files for activated groups diff --git a/src/main/java/com/threerings/getdown/launcher/GetdownApp.java b/src/main/java/com/threerings/getdown/launcher/GetdownApp.java index fb68080..0dac4a1 100644 --- a/src/main/java/com/threerings/getdown/launcher/GetdownApp.java +++ b/src/main/java/com/threerings/getdown/launcher/GetdownApp.java @@ -88,7 +88,7 @@ public class GetdownApp // load X.509 certificate if it exists File crtFile = new File(appDir, Digest.digestFile(Digest.VERSION) + ".crt"); - List crts = new ArrayList(); + List crts = new ArrayList<>(); if (crtFile.exists()) { try { FileInputStream fis = new FileInputStream(crtFile); @@ -148,7 +148,7 @@ public class GetdownApp } if (_ifc.iconImages != null) { - ArrayList icons = new ArrayList(); + ArrayList icons = new ArrayList<>(); for (String path : _ifc.iconImages) { Image img = loadImage(path); if (img == null) { diff --git a/src/main/java/com/threerings/getdown/launcher/GetdownApplet.java b/src/main/java/com/threerings/getdown/launcher/GetdownApplet.java index 1e581f4..8f10b96 100644 --- a/src/main/java/com/threerings/getdown/launcher/GetdownApplet.java +++ b/src/main/java/com/threerings/getdown/launcher/GetdownApplet.java @@ -85,7 +85,7 @@ public class GetdownApplet extends JApplet _errmsg = e.getMessage(); } - List signers = new ArrayList(); + List signers = new ArrayList<>(); Certificate cert = loadCertificate("resource.crt"); if (cert != null) { signers.add(cert); diff --git a/src/main/java/com/threerings/getdown/launcher/GetdownAppletConfig.java b/src/main/java/com/threerings/getdown/launcher/GetdownAppletConfig.java index fd38511..a813ebd 100644 --- a/src/main/java/com/threerings/getdown/launcher/GetdownAppletConfig.java +++ b/src/main/java/com/threerings/getdown/launcher/GetdownAppletConfig.java @@ -299,7 +299,7 @@ public class GetdownAppletConfig */ protected List parseArgList (String prefix) { - List arglist = new ArrayList(); + List arglist = new ArrayList<>(); String value; for (int ii = 0; (value = getParameter(prefix + ii)) != null; ii++) { arglist.add(value); diff --git a/src/main/java/com/threerings/getdown/net/Downloader.java b/src/main/java/com/threerings/getdown/net/Downloader.java index 4d80c66..f88034a 100644 --- a/src/main/java/com/threerings/getdown/net/Downloader.java +++ b/src/main/java/com/threerings/getdown/net/Downloader.java @@ -234,10 +234,10 @@ public abstract class Downloader extends Thread protected Collection _resources; /** The reported sizes of our resources. */ - protected Map _sizes = new HashMap(); + protected Map _sizes = new HashMap<>(); /** The bytes downloaded for each resource. */ - protected Map _downloaded = new HashMap(); + protected Map _downloaded = new HashMap<>(); /** The observer with whom we are communicating. */ protected Observer _obs; diff --git a/src/main/java/com/threerings/getdown/tools/Differ.java b/src/main/java/com/threerings/getdown/tools/Differ.java index fbde2a9..74a8dc2 100644 --- a/src/main/java/com/threerings/getdown/tools/Differ.java +++ b/src/main/java/com/threerings/getdown/tools/Differ.java @@ -60,13 +60,13 @@ public class Differ Application oapp = new Application(ovdir, null); oapp.init(false); - ArrayList orsrcs = new ArrayList(); + ArrayList orsrcs = new ArrayList<>(); orsrcs.addAll(oapp.getCodeResources()); orsrcs.addAll(oapp.getResources()); Application napp = new Application(nvdir, null); napp.init(false); - ArrayList nrsrcs = new ArrayList(); + ArrayList nrsrcs = new ArrayList<>(); nrsrcs.addAll(napp.getCodeResources()); nrsrcs.addAll(napp.getResources()); @@ -76,13 +76,13 @@ public class Differ // next create patches for any auxiliary resource groups for (Application.AuxGroup ag : napp.getAuxGroups()) { - orsrcs = new ArrayList(); + orsrcs = new ArrayList<>(); Application.AuxGroup oag = oapp.getAuxGroup(ag.name); if (oag != null) { orsrcs.addAll(oag.codes); orsrcs.addAll(oag.rsrcs); } - nrsrcs = new ArrayList(); + nrsrcs = new ArrayList<>(); nrsrcs.addAll(ag.codes); nrsrcs.addAll(ag.rsrcs); patch = new File(nvdir, "patch-" + ag.name + overs + ".dat"); diff --git a/src/main/java/com/threerings/getdown/tools/Digester.java b/src/main/java/com/threerings/getdown/tools/Digester.java index a3738c3..86a0331 100644 --- a/src/main/java/com/threerings/getdown/tools/Digester.java +++ b/src/main/java/com/threerings/getdown/tools/Digester.java @@ -76,7 +76,7 @@ public class Digester Application app = new Application(appdir, null); app.init(false); - List rsrcs = new ArrayList(); + List rsrcs = new ArrayList<>(); rsrcs.add(app.getConfigResource()); rsrcs.addAll(app.getCodeResources()); rsrcs.addAll(app.getResources()); diff --git a/src/main/java/com/threerings/getdown/tools/JarDiff.java b/src/main/java/com/threerings/getdown/tools/JarDiff.java index 0091881..ccc8d39 100644 --- a/src/main/java/com/threerings/getdown/tools/JarDiff.java +++ b/src/main/java/com/threerings/getdown/tools/JarDiff.java @@ -73,10 +73,10 @@ public class JarDiff implements JarDiffCodes JarFile2 newJar = new JarFile2(newPath); try { - HashMap moved = new HashMap(); - HashSet implicit = new HashSet(); - HashSet moveSrc = new HashSet(); - HashSet newEntries = new HashSet(); + HashMap moved = new HashMap<>(); + HashSet implicit = new HashSet<>(); + HashSet moveSrc = new HashSet<>(); + HashSet newEntries = new HashSet<>(); // FIRST PASS // Go through the entries in new jar and @@ -152,7 +152,7 @@ public class JarDiff implements JarDiffCodes // SECOND PASS: = - - // - - ArrayList deleted = new ArrayList(); + ArrayList deleted = new ArrayList<>(); for (JarEntry oldEntry : oldJar) { String oldName = oldEntry.getName(); if (!implicit.contains(oldName) && !moveSrc.contains(oldName) @@ -452,9 +452,9 @@ public class JarDiff implements JarDiffCodes private void index () throws IOException { Enumeration entries = _jar.entries(); - _nameToEntryMap = new HashMap(); - _crcToEntryMap = new HashMap>(); - _entries = new ArrayList(); + _nameToEntryMap = new HashMap<>(); + _crcToEntryMap = new HashMap<>(); + _entries = new ArrayList<>(); if (_debug) { System.out.println("indexing: " + _jar.getName()); } diff --git a/src/main/java/com/threerings/getdown/tools/JarDiffPatcher.java b/src/main/java/com/threerings/getdown/tools/JarDiffPatcher.java index 1e5cd70..ff96cb6 100644 --- a/src/main/java/com/threerings/getdown/tools/JarDiffPatcher.java +++ b/src/main/java/com/threerings/getdown/tools/JarDiffPatcher.java @@ -54,16 +54,16 @@ public class JarDiffPatcher implements JarDiffCodes jos = new JarOutputStream(new FileOutputStream(target)); oldJar = new JarFile(oldFile); jarDiff = new JarFile(diffFile); - Set ignoreSet = new HashSet(); + Set ignoreSet = new HashSet<>(); - Map renameMap = new HashMap(); + Map renameMap = new HashMap<>(); determineNameMapping(jarDiff, ignoreSet, renameMap); // get all keys in renameMap String[] keys = renameMap.keySet().toArray(new String[renameMap.size()]); // Files to implicit move - Set oldjarNames = new HashSet(); + Set oldjarNames = new HashSet<>(); Enumeration oldEntries = oldJar.entries(); if (oldEntries != null) { while (oldEntries.hasMoreElements()) { @@ -223,7 +223,7 @@ public class JarDiffPatcher implements JarDiffCodes { int index = 0; int length = path.length(); - ArrayList sub = new ArrayList(); + ArrayList sub = new ArrayList<>(); while (index < length) { while (index < length && Character.isWhitespace diff --git a/src/main/java/com/threerings/getdown/util/ConfigUtil.java b/src/main/java/com/threerings/getdown/util/ConfigUtil.java index adda285..3284b26 100644 --- a/src/main/java/com/threerings/getdown/util/ConfigUtil.java +++ b/src/main/java/com/threerings/getdown/util/ConfigUtil.java @@ -72,7 +72,7 @@ public class ConfigUtil */ public static List parsePairs (Reader source, ParseOpts opts) throws IOException { - List pairs = new ArrayList(); + List pairs = new ArrayList<>(); for (String line : FileUtil.readLines(source)) { // nix comments int cidx = line.indexOf("#"); @@ -133,7 +133,7 @@ public class ConfigUtil public static Map parseConfig (File source, ParseOpts opts) throws IOException { - Map data = new HashMap(); + Map data = new HashMap<>(); // I thought that we could use HashMap and put new String[] {pair[1]} for // the null case, but it mysteriously dies on launch, so leaving it as HashMap readLines (Reader in) throws IOException { - List lines = new ArrayList(); + List lines = new ArrayList<>(); try { BufferedReader bin = new BufferedReader(in); for (String line = null; (line = bin.readLine()) != null; lines.add(line)) {} @@ -156,7 +156,7 @@ public class FileUtil extends com.samskivert.util.FileUtil */ public static void walkTree (File root, Visitor visitor) { - Deque stack = new ArrayDeque(Arrays.asList(root.listFiles())); + Deque stack = new ArrayDeque<>(Arrays.asList(root.listFiles())); while (!stack.isEmpty()) { File currentFile = stack.pop(); if (currentFile.exists()) {