Make fields final. Remove redundant modifier on final-class

This commit is contained in:
Anosh D. Ullenius
2022-06-17 20:20:05 +02:00
parent 29437aa993
commit a4e38057ae
16 changed files with 48 additions and 45 deletions
@@ -129,7 +129,7 @@ public final class Log
PrintWriter pw = new PrintWriter(sw); PrintWriter pw = new PrintWriter(sw);
record.getThrown().printStackTrace(pw); record.getThrown().printStackTrace(pw);
pw.close(); pw.close();
buf.append(sw.toString()); buf.append(sw);
} catch (Exception ex) { } catch (Exception ex) {
buf.append("Format failure:").append(ex); buf.append("Format failure:").append(ex);
} }
@@ -138,9 +138,9 @@ public final class Log
return buf.toString(); return buf.toString();
} }
protected Date _date = new Date(); protected final Date _date = new Date();
protected SimpleDateFormat _format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS"); protected final SimpleDateFormat _format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS");
protected FieldPosition _fpos = new FieldPosition(SimpleDateFormat.DATE_FIELD); protected final FieldPosition _fpos = new FieldPosition(SimpleDateFormat.DATE_FIELD);
} }
protected static final Level[] LEVELS = {Level.FINE, Level.INFO, Level.WARNING, Level.SEVERE}; protected static final Level[] LEVELS = {Level.FINE, Level.INFO, Level.WARNING, Level.SEVERE};
@@ -1793,10 +1793,10 @@ public class Application
protected String _javaLocation; protected String _javaLocation;
protected File _javaLocalDir; protected File _javaLocalDir;
protected List<Resource> _codes = new ArrayList<>(); protected final List<Resource> _codes = new ArrayList<>();
protected List<Resource> _resources = new ArrayList<>(); protected final List<Resource> _resources = new ArrayList<>();
protected List<String> _cleanupPatterns = new ArrayList<>(); protected final List<String> _cleanupPatterns = new ArrayList<>();
protected List<String> _cpdirs = new ArrayList<>(); protected final List<String> _cpdirs = new ArrayList<>();
protected int _verifyTimeout = 60; protected int _verifyTimeout = 60;
@@ -1804,15 +1804,15 @@ public class Application
protected boolean _useCodeCache; protected boolean _useCodeCache;
protected int _codeCacheRetentionDays; protected int _codeCacheRetentionDays;
protected Map<String,AuxGroup> _auxgroups = new HashMap<>(); protected final Map<String,AuxGroup> _auxgroups = new HashMap<>();
protected Map<String,Boolean> _auxactive = new HashMap<>(); protected final Map<String,Boolean> _auxactive = new HashMap<>();
protected List<String> _jvmargs = new ArrayList<>(); protected final List<String> _jvmargs = new ArrayList<>();
protected List<String> _appargs = new ArrayList<>(); protected final List<String> _appargs = new ArrayList<>();
protected String[] _optimumJvmArgs; protected String[] _optimumJvmArgs;
protected List<String> _txtJvmArgs = new ArrayList<>(); protected final List<String> _txtJvmArgs = new ArrayList<>();
/** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/ /** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/
protected FileLock _lock; protected FileLock _lock;
@@ -1820,7 +1820,7 @@ public class Application
/** Channel to the file underlying _lock. Kept around solely so the lock doesn't close. */ /** Channel to the file underlying _lock. Kept around solely so the lock doesn't close. */
protected FileChannel _lockChannel; protected FileChannel _lockChannel;
protected Random _rando = new Random(); protected final Random _rando = new Random();
protected static final String[] EMPTY_STRING_ARRAY = new String[0]; protected static final String[] EMPTY_STRING_ARRAY = new String[0];
@@ -219,7 +219,7 @@ public class Digest
data.append(path).append(" = ").append(digest).append("\n"); data.append(path).append(" = ").append(digest).append("\n");
} }
protected HashMap<String, String> _digests = new HashMap<>(); protected final HashMap<String, String> _digests = new HashMap<>();
protected String _metaDigest = ""; protected String _metaDigest = "";
protected static final String FILE_NAME = "digest"; protected static final String FILE_NAME = "digest";
@@ -362,11 +362,14 @@ public class Resource implements Comparable<Resource>
} }
} }
protected String _path; protected final String _path;
protected URL _remote; protected final URL _remote;
protected File _local, _localNew, _marker, _unpacked; protected final File _local;
protected EnumSet<Attr> _attrs; protected final File _localNew;
protected boolean _isZip; protected final File _marker;
protected File _unpacked;
protected final EnumSet<Attr> _attrs;
protected final boolean _isZip;
/** Used to sort the entries in a jar file. */ /** Used to sort the entries in a jar file. */
protected static final Comparator<ZipEntry> ENTRY_COMP = new Comparator<ZipEntry>() { protected static final Comparator<ZipEntry> ENTRY_COMP = new Comparator<ZipEntry>() {
@@ -292,6 +292,6 @@ public class JarDiffPatcher implements JarDiffCodes
protected static final int DEFAULT_READ_SIZE = 2048; protected static final int DEFAULT_READ_SIZE = 2048;
protected static byte[] newBytes = new byte[DEFAULT_READ_SIZE]; protected static final byte[] newBytes = new byte[DEFAULT_READ_SIZE];
protected static byte[] oldBytes = new byte[DEFAULT_READ_SIZE]; protected static byte[] oldBytes = new byte[DEFAULT_READ_SIZE];
} }
@@ -154,7 +154,7 @@ public final class FileUtil
continue; continue;
} }
try (BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream(efile)); try (BufferedOutputStream fout = new BufferedOutputStream(Files.newOutputStream(efile.toPath()));
InputStream jin = jar.getInputStream(entry)) { InputStream jin = jar.getInputStream(entry)) {
StreamUtil.copy(jin, fout); StreamUtil.copy(jin, fout);
} catch (Exception e) { } catch (Exception e) {
@@ -44,7 +44,7 @@ public class ProgressAggregator
return totalSize; return totalSize;
} }
protected ProgressObserver _target; protected final ProgressObserver _target;
protected long[] _sizes; protected final long[] _sizes;
protected int[] _progress; protected final int[] _progress;
} }
@@ -77,7 +77,7 @@ public class GarbageCollectorTest
assertFalse(_lastAccessedFile.exists()); assertFalse(_lastAccessedFile.exists());
} }
@Rule public TemporaryFolder _folder = new TemporaryFolder(); @Rule public final TemporaryFolder _folder = new TemporaryFolder();
private File _cachedFile; private File _cachedFile;
private File _lastAccessedFile; private File _lastAccessedFile;
@@ -47,7 +47,7 @@ public class ClassPathTest
assertEquals(_secondJar, new File(actualUrls[1].toURI())); assertEquals(_secondJar, new File(actualUrls[1].toURI()));
} }
@Rule public TemporaryFolder _folder = new TemporaryFolder(); @Rule public final TemporaryFolder _folder = new TemporaryFolder();
private File _firstJar, _secondJar; private File _firstJar, _secondJar;
private ClassPath _classPath; private ClassPath _classPath;
@@ -15,9 +15,9 @@ import static org.junit.Assert.*;
public class EnvConfigTest { public class EnvConfigTest {
static String CWD = System.getProperty("user.dir"); static final String CWD = System.getProperty("user.dir");
static String TESTID = "testid"; static final String TESTID = "testid";
static String TESTBASE = "https://test.com/test"; static final String TESTBASE = "https://test.com/test";
private void debugNotes (List<EnvConfig.Note> notes) { private void debugNotes (List<EnvConfig.Note> notes) {
for (EnvConfig.Note note : notes) { for (EnvConfig.Note note : notes) {
@@ -33,7 +33,7 @@ public class EnvConfigTest {
} }
} }
if (msg.length() > 0) { if (msg.length() > 0) {
fail("Unexpected notes:" + msg.toString()); fail("Unexpected notes:" + msg);
} }
} }
private void checkDir (EnvConfig cfg) { private void checkDir (EnvConfig cfg) {
@@ -55,5 +55,5 @@ public class PathBuilderTest
protected File _firstJarFile, _secondJarFile; protected File _firstJarFile, _secondJarFile;
@Rule public TemporaryFolder _appdir = new TemporaryFolder(); @Rule public final TemporaryFolder _appdir = new TemporaryFolder();
} }
@@ -167,5 +167,5 @@ public class ConfigTest
return _rando.nextBoolean() ? " " : ""; return _rando.nextBoolean() ? " " : "";
} }
protected static Random _rando = new Random(); protected static final Random _rando = new Random();
} }
@@ -56,5 +56,5 @@ public class FileUtilTest
assertEquals(3, visitor.fileCount); assertEquals(3, visitor.fileCount);
} }
@Rule public TemporaryFolder _folder = new TemporaryFolder(); @Rule public final TemporaryFolder _folder = new TemporaryFolder();
} }
@@ -80,7 +80,7 @@ public final class AbortPanel extends JFrame
} }
/** Used to look up localized messages. */ /** Used to look up localized messages. */
protected String get (String key) private String get(String key)
{ {
// if this string is tainted, we don't translate it, instead we // if this string is tainted, we don't translate it, instead we
// simply remove the taint character and return it to the caller // simply remove the taint character and return it to the caller
@@ -95,6 +95,6 @@ public final class AbortPanel extends JFrame
} }
} }
protected Getdown _getdown; private final Getdown _getdown;
protected ResourceBundle _msgs; private final ResourceBundle _msgs;
} }
@@ -1113,13 +1113,13 @@ public abstract class Getdown
} }
/** Used to pass progress on to our user interface. */ /** Used to pass progress on to our user interface. */
protected ProgressObserver _progobs = new ProgressObserver() { protected final ProgressObserver _progobs = new ProgressObserver() {
public void progress (int percent) { public void progress (int percent) {
setStatusAsync(null, stepToGlobalPercent(percent), -1L, false); setStatusAsync(null, stepToGlobalPercent(percent), -1L, false);
} }
}; };
protected Application _app; protected final Application _app;
protected Application.UpdateInterface _ifc = new Application.UpdateInterface(Config.EMPTY); protected Application.UpdateInterface _ifc = new Application.UpdateInterface(Config.EMPTY);
protected ResourceBundle _msgs; protected ResourceBundle _msgs;
@@ -1134,7 +1134,7 @@ public abstract class Getdown
protected boolean _silent; protected boolean _silent;
protected boolean _launchInSilent; protected boolean _launchInSilent;
protected boolean _noUpdate; protected boolean _noUpdate;
protected long _startup; protected final long _startup;
protected Set<Resource> _toInstallResources; protected Set<Resource> _toInstallResources;
protected boolean _readyToInstall; protected boolean _readyToInstall;
@@ -197,9 +197,9 @@ public final class ProxyPanel extends JPanel implements ActionListener
protected final ResourceBundle _msgs; protected final ResourceBundle _msgs;
protected final boolean _updateAuth; protected final boolean _updateAuth;
protected JTextField _host; protected final JTextField _host;
protected JTextField _port; protected final JTextField _port;
protected JCheckBox _useAuth; protected final JCheckBox _useAuth;
protected JTextField _username; protected final JTextField _username;
protected JPasswordField _password; protected final JPasswordField _password;
} }