JDK-8213244: Fix all warnings in jpackager java code JDK-8200758-branch
authorherrick
Thu, 01 Nov 2018 14:36:18 -0400
branchJDK-8200758-branch
changeset 57015 5d2008115309
parent 57014 d3a84ae11429
child 57016 f63f13da91c0
JDK-8213244: Fix all warnings in jpackager java code Reviewed-by: almatvee
make/CompileJavaModules.gmk
src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxRpmBundler.java
src/jdk.packager/share/classes/jdk/packager/internal/AbstractBundler.java
src/jdk.packager/share/classes/jdk/packager/internal/Arguments.java
src/jdk.packager/share/classes/jdk/packager/internal/BundlerParamInfo.java
src/jdk.packager/share/classes/jdk/packager/internal/ConfigException.java
src/jdk.packager/share/classes/jdk/packager/internal/InvalidBundlerParamException.java
src/jdk.packager/share/classes/jdk/packager/internal/JLinkBundlerHelper.java
src/jdk.packager/share/classes/jdk/packager/internal/ModuleManager.java
src/jdk.packager/share/classes/jdk/packager/internal/PackagerException.java
src/jdk.packager/share/classes/jdk/packager/internal/RedistributableModules.java
src/jdk.packager/share/classes/jdk/packager/internal/SecondaryLauncherArguments.java
src/jdk.packager/share/classes/jdk/packager/internal/StandardBundlerParam.java
src/jdk.packager/share/classes/jdk/packager/internal/UnsupportedPlatformException.java
src/jdk.packager/share/classes/jdk/packager/internal/bundlers/BundleParams.java
src/jdk.packager/windows/classes/jdk/packager/internal/resources/windows/template.jre.iss
src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinExeBundler.java
src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinMsiBundler.java
src/jdk.packager/windows/classes/jdk/packager/internal/windows/WindowsRegistry.java
--- a/make/CompileJavaModules.gmk	Thu Nov 01 09:01:15 2018 -0400
+++ b/make/CompileJavaModules.gmk	Thu Nov 01 14:36:18 2018 -0400
@@ -386,7 +386,6 @@
 
 jdk.packager_ADD_JAVAC_FLAGS += -parameters -XDstringConcat=inline
 
-jdk.packager_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
 jdk.packager_COPY += .gif .png .txt .spec .script .prerm .preinst .postrm .postinst .list \
     .desktop .copyright .control .plist .template .icns .scpt .entitlements .wxs .iss .ico .bmp
 
--- a/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxRpmBundler.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxRpmBundler.java	Thu Nov 01 14:36:18 2018 -0400
@@ -183,7 +183,7 @@
 
             if (matcher.find()) {
                 String v = matcher.group(1);
-                double version = new Double(v);
+                double version = Double.parseDouble(v);
                 return minVersion <= version;
             } else {
                return false;
--- a/src/jdk.packager/share/classes/jdk/packager/internal/AbstractBundler.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/AbstractBundler.java	Thu Nov 01 14:36:18 2018 -0400
@@ -63,7 +63,7 @@
     // we use it for classpath lookup and there / are not platform specific
     public final static String BUNDLER_PREFIX = "package/";
 
-    protected Class baseResourceLoader = null;
+    protected Class<?> baseResourceLoader = null;
 
     protected void fetchResource(String publicName, String category,
             String defaultName, File result, boolean verbose, File publicRoot)
--- a/src/jdk.packager/share/classes/jdk/packager/internal/Arguments.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/Arguments.java	Thu Nov 01 14:36:18 2018 -0400
@@ -771,7 +771,6 @@
         Properties properties = new Properties();
         try (FileInputStream in = new FileInputStream(file)) {
             properties.load(in);
-            in.close();
         } catch (IOException e) {
             Log.info("Exception: " + e.getMessage());
         }
--- a/src/jdk.packager/share/classes/jdk/packager/internal/BundlerParamInfo.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/BundlerParamInfo.java	Thu Nov 01 14:36:18 2018 -0400
@@ -130,7 +130,7 @@
             return getStringConverter().apply((String)o, params);
         }
 
-        Class klass = getValueType();
+        Class<T> klass = getValueType();
         if (klass.isInstance(o)) {
             return (T) o;
         }
--- a/src/jdk.packager/share/classes/jdk/packager/internal/ConfigException.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/ConfigException.java	Thu Nov 01 14:36:18 2018 -0400
@@ -26,6 +26,7 @@
 package jdk.packager.internal;
 
 public class ConfigException extends Exception {
+    private static final long serialVersionUID = 1L;
     final String advice;
 
     public ConfigException(String msg, String advice) {
--- a/src/jdk.packager/share/classes/jdk/packager/internal/InvalidBundlerParamException.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/InvalidBundlerParamException.java	Thu Nov 01 14:36:18 2018 -0400
@@ -26,6 +26,7 @@
 package jdk.packager.internal;
 
 public class InvalidBundlerParamException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
     public InvalidBundlerParamException(String message) {
         super(message);
     }
--- a/src/jdk.packager/share/classes/jdk/packager/internal/JLinkBundlerHelper.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/JLinkBundlerHelper.java	Thu Nov 01 14:36:18 2018 -0400
@@ -365,7 +365,7 @@
 
     private static Set<String> getResourceFileJarList(
             Map<String, ? super Object> params, ModFile.JarType Query) {
-        Set<String> files = new LinkedHashSet();
+        Set<String> files = new LinkedHashSet<String>();
 
         String srcdir = StandardBundlerParam.SOURCE_DIR.fetchFrom(params);
 
@@ -404,7 +404,7 @@
 
     private static Set<String> removeInvalidModules(
             List<Path> modulePath, Set<String> modules) {
-        Set<String> result = new LinkedHashSet();
+        Set<String> result = new LinkedHashSet<String>();
         ModuleManager mm = new ModuleManager(modulePath);
         List<ModFile> lmodfiles =
                 mm.getModules(EnumSet.of(ModuleManager.SearchType.ModularJar,
@@ -484,7 +484,7 @@
         }
 
         private static Set<String> getModuleNamesFromPath(List<Path> Value) {
-                Set<String> result = new LinkedHashSet();
+                Set<String> result = new LinkedHashSet<String>();
                 ModuleManager mm = new ModuleManager(Value);
                 List<ModFile> modFiles =
                         mm.getModules(
--- a/src/jdk.packager/share/classes/jdk/packager/internal/ModuleManager.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/ModuleManager.java	Thu Nov 01 14:36:18 2018 -0400
@@ -33,14 +33,14 @@
 import java.util.List;
 
 public final class ModuleManager {
-    private final List<String> folders = new ArrayList();
+    private final List<String> folders = new ArrayList<String>();
 
     public enum SearchType {UnnamedJar, ModularJar, Jmod, ExplodedModule}
 
     public ModuleManager(String folders) {
         super();
         String lfolders = folders.replaceAll("^\"|\"$", "");
-        List<Path> paths = new ArrayList();
+        List<Path> paths = new ArrayList<Path>();
 
         for (String folder :
                 Arrays.asList(lfolders.split(File.pathSeparator))) {
@@ -69,7 +69,7 @@
     }
 
     public List<ModFile> getModules(EnumSet<SearchType> Search) {
-        List<ModFile> result = new ArrayList();
+        List<ModFile> result = new ArrayList<ModFile>();
 
         for (String folder : folders) {
             result.addAll(getAllModulesInDirectory(folder, Search));
@@ -80,7 +80,7 @@
 
     private static List<ModFile> getAllModulesInDirectory(String Folder,
             EnumSet<SearchType> Search) {
-        List<ModFile> result = new ArrayList();
+        List<ModFile> result = new ArrayList<ModFile>();
         File lfolder = new File(Folder);
         File[] files = lfolder.listFiles();
 
--- a/src/jdk.packager/share/classes/jdk/packager/internal/PackagerException.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/PackagerException.java	Thu Nov 01 14:36:18 2018 -0400
@@ -29,6 +29,7 @@
 import java.util.ResourceBundle;
 
 public class PackagerException extends Exception {
+    private static final long serialVersionUID = 1L;
     private static final ResourceBundle bundle =
             ResourceBundle.getBundle("jdk.packager.internal.resources.Bundle");
 
--- a/src/jdk.packager/share/classes/jdk/packager/internal/RedistributableModules.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/RedistributableModules.java	Thu Nov 01 14:36:18 2018 -0400
@@ -99,7 +99,7 @@
                         }
 
                         if (br != null) {
-                            result = new LinkedHashSet();
+                            result = new LinkedHashSet<String>();
                             String line;
 
                             try {
--- a/src/jdk.packager/share/classes/jdk/packager/internal/SecondaryLauncherArguments.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/SecondaryLauncherArguments.java	Thu Nov 01 14:36:18 2018 -0400
@@ -152,14 +152,14 @@
     }
 
     private void putUnlessNullOrEmpty(Map<String, ? super Object> params,
-            String param, Collection value) {
+            String param, Collection<?> value) {
         if (value != null && !value.isEmpty()) {
             params.put(param, value);
         }
     }
 
     private void putUnlessNullOrEmpty(Map<String, ? super Object> params,
-            String param, Map value) {
+            String param, Map<?, ?> value) {
         if (value != null && !value.isEmpty()) {
             params.put(param, value);
         }
--- a/src/jdk.packager/share/classes/jdk/packager/internal/StandardBundlerParam.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/StandardBundlerParam.java	Thu Nov 01 14:36:18 2018 -0400
@@ -112,7 +112,6 @@
                     StandardBundlerParam::createAppResourcesListFromString
             );
 
-    @SuppressWarnings("unchecked")
     public static final StandardBundlerParam<String> SOURCE_DIR =
             new StandardBundlerParam<>(
                     I18N.getString("param.source-dir.name"),
@@ -132,6 +131,7 @@
                     }
             );
 
+    @SuppressWarnings("unchecked")
     public static final StandardBundlerParam<List<File>> SOURCE_FILES =
             new StandardBundlerParam<>(
                     I18N.getString("param.source-files.name"),
@@ -544,9 +544,8 @@
                         if (modulePath != null) {
                             javaBasePath = JLinkBundlerHelper
                                     .findPathOfModule(modulePath, JAVABASEJMOD);
-                        }
-                        else {
-                            modulePath = new ArrayList();
+                        } else {
+                            modulePath = new ArrayList<Path>();
                         }
 
                         // Add the default JDK module path to the module path.
@@ -571,7 +570,6 @@
                         return modulePath;
                     });
 
-    @SuppressWarnings("unchecked")
     public static final BundlerParamInfo<String> MODULE =
             new StandardBundlerParam<>(
                     I18N.getString("param.main.module.name"),
@@ -590,7 +588,7 @@
                     I18N.getString("param.add-modules.description"),
                     Arguments.CLIOptions.ADD_MODULES.getId(),
                     (Class<Set<String>>) (Object) Set.class,
-                    p -> new LinkedHashSet(),
+                    p -> new LinkedHashSet<String>(),
                     (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
             );
 
@@ -601,11 +599,10 @@
                     I18N.getString("param.limit-modules.description"),
                     Arguments.CLIOptions.LIMIT_MODULES.getId(),
                     (Class<Set<String>>) (Object) Set.class,
-                    p -> new LinkedHashSet(),
+                    p -> new LinkedHashSet<String>(),
                     (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
             );
 
-    @SuppressWarnings("unchecked")
     public static final BundlerParamInfo<Boolean> STRIP_NATIVE_COMMANDS =
             new StandardBundlerParam<>(
                     I18N.getString("param.strip-executables.name"),
@@ -869,7 +866,7 @@
     }
 
     public static List<Path> getDefaultModulePath() {
-        List<Path> result = new ArrayList();
+        List<Path> result = new ArrayList<Path>();
         Path jdkModulePath = Paths.get(
                 System.getProperty("java.home"), "jmods").toAbsolutePath();
 
--- a/src/jdk.packager/share/classes/jdk/packager/internal/UnsupportedPlatformException.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/UnsupportedPlatformException.java	Thu Nov 01 14:36:18 2018 -0400
@@ -26,4 +26,5 @@
 package jdk.packager.internal;
 
 public class UnsupportedPlatformException extends Exception {
+    private static final long serialVersionUID = 1L;
 }
--- a/src/jdk.packager/share/classes/jdk/packager/internal/bundlers/BundleParams.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/bundlers/BundleParams.java	Thu Nov 01 14:36:18 2018 -0400
@@ -475,13 +475,13 @@
         }
     }
 
-    public void putUnlessNullOrEmpty(String param, Collection value) {
+    public void putUnlessNullOrEmpty(String param, Collection<?> value) {
         if (value != null && !value.isEmpty()) {
             params.put(param, value);
         }
     }
 
-    public void putUnlessNullOrEmpty(String param, Map value) {
+    public void putUnlessNullOrEmpty(String param, Map<?,?> value) {
         if (value != null && !value.isEmpty()) {
             params.put(param, value);
         }
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/resources/windows/template.jre.iss	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/resources/windows/template.jre.iss	Thu Nov 01 14:36:18 2018 -0400
@@ -1,14 +1,14 @@
 ;This file will be executed next to the application bundle image
-;I.e. current directory will contain folder APPLICATION_NAME with application files
+;I.e. current directory will contain folder INSTALLER_NAME with application files
 [Setup]
 AppId={{PRODUCT_APP_IDENTIFIER}}
-AppName=APPLICATION_NAME
+AppName=INSTALLER_NAME
 AppVersion=APPLICATION_VERSION
-AppVerName=APPLICATION_NAME APPLICATION_VERSION
+AppVerName=INSTALLER_NAME APPLICATION_VERSION
 AppPublisher=APPLICATION_VENDOR
 AppComments=APPLICATION_COMMENTS
 AppCopyright=APPLICATION_COPYRIGHT
-DefaultDirName=APPLICATION_INSTALL_ROOT\APPLICATION_NAME
+DefaultDirName=APPLICATION_INSTALL_ROOT\INSTALLER_NAME
 DisableStartupPrompt=Yes
 DisableDirPage=DISABLE_DIR_PAGE
 DisableProgramGroupPage=Yes
@@ -26,9 +26,9 @@
 PrivilegesRequired=APPLICATION_INSTALL_PRIVILEGE
 SetupIconFile=
 UninstallDisplayIcon=
-UninstallDisplayName=APPLICATION_NAME
+UninstallDisplayName=INSTALLER_NAME
 WizardImageStretch=No
-WizardSmallImageFile=APPLICATION_NAME-setup-icon.bmp   
+WizardSmallImageFile=INSTALLER_NAME-setup-icon.bmp   
 ArchitecturesInstallIn64BitMode=ARCHITECTURE_BIT_MODE
 FILE_ASSOCIATIONS
 
@@ -36,7 +36,7 @@
 Name: "english"; MessagesFile: "compiler:Default.isl"
 
 [Files]
-Source: "APPLICATION_NAME\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
+Source: "INSTALLER_NAME\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
 
 [Code]
 function returnTrue(): Boolean;
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinExeBundler.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinExeBundler.java	Thu Nov 01 14:36:18 2018 -0400
@@ -234,7 +234,7 @@
                 Matcher matcher = pattern.matcher(content);
                 if (matcher.find()) {
                     String v = matcher.group(1);
-                    version = new Double(v);
+                    version = Double.parseDouble(v);
                 }
             }
             return version;
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinMsiBundler.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinMsiBundler.java	Thu Nov 01 14:36:18 2018 -0400
@@ -286,7 +286,7 @@
                 Matcher matcher = pattern.matcher(content);
                 if (matcher.find()) {
                     String v = matcher.group(1);
-                    version = new Double(v);
+                    version = Double.parseDouble(v);
                 }
             }
             return version;
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WindowsRegistry.java	Thu Nov 01 09:01:15 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WindowsRegistry.java	Thu Nov 01 14:36:18 2018 -0400
@@ -76,7 +76,7 @@
     }
 
     public static final List<String> readExclusionsPaths() {
-        List<String> result = new ArrayList();
+        List<String> result = new ArrayList<String>();
         final String key = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\"
                 + "Windows Defender\\Exclusions\\Paths";
         String value = readRegistry(key, "");