8160459: jlink minor code clean up
authorjlaskey
Tue, 28 Jun 2016 16:07:23 -0300
changeset 39308 f6517755057f
parent 39307 35eab41d2df1
child 39309 1a3bcf3d6034
8160459: jlink minor code clean up Reviewed-by: mchung
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java	Tue Jun 28 16:07:23 2016 -0300
@@ -25,7 +25,6 @@
 
 package jdk.tools.jlink.internal;
 
-import java.io.InputStream;
 import java.util.Objects;
 import jdk.tools.jlink.plugin.ModuleEntry;
 
@@ -77,9 +76,7 @@
 
     @Override
     public int hashCode() {
-        int hash = 7;
-        hash = 89 * hash + Objects.hashCode(this.path);
-        return hash;
+        return Objects.hashCode(this.path);
     }
 
     @Override
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java	Tue Jun 28 16:07:23 2016 -0300
@@ -42,7 +42,6 @@
     public abstract class Entry {
 
         public static enum EntryType {
-
             MODULE_NAME,
             CLASS_OR_RESOURCE,
             NATIVE_LIB,
@@ -57,14 +56,10 @@
         private final String path;
 
         public Entry(Archive archive, String path, String name, EntryType type) {
-            Objects.requireNonNull(archive);
-            Objects.requireNonNull(path);
-            Objects.requireNonNull(name);
-            Objects.requireNonNull(type);
-            this.archive = archive;
-            this.path = path;
-            this.name = name;
-            this.type = type;
+            this.archive = Objects.requireNonNull(archive);
+            this.path = Objects.requireNonNull(path);
+            this.name = Objects.requireNonNull(name);
+            this.type = Objects.requireNonNull(type);
         }
 
         public Archive archive() {
@@ -79,7 +74,7 @@
             return type;
         }
 
-        /**
+        /*
          * Returns the name of this entry.
          */
         public String name() {
@@ -91,7 +86,7 @@
             return "type " + type.name() + " path " + path;
         }
 
-        /**
+        /*
          * Returns the number of uncompressed bytes for this entry.
          */
         public abstract long size();
@@ -99,17 +94,17 @@
         public abstract InputStream stream() throws IOException;
     }
 
-    /**
+    /*
      * The module name.
      */
     String moduleName();
 
-    /**
+    /*
      * Returns the path to this module's content
      */
     Path getPath();
 
-    /**
+    /*
      * Stream of Entry.
      * The stream of entries needs to be closed after use
      * since it might cover lazy I/O based resources.
@@ -117,12 +112,12 @@
      */
     Stream<Entry> entries();
 
-    /**
+    /*
      * Open the archive
      */
     void open() throws IOException;
 
-    /**
+    /*
      * Close the archive
      */
     void close() throws IOException;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java	Tue Jun 28 16:07:23 2016 -0300
@@ -25,7 +25,6 @@
 
 package jdk.tools.jlink.internal;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UncheckedIOException;
@@ -46,7 +45,7 @@
      * @param entry The archive Entry.
      */
     ArchiveEntryModuleEntry(String module, String path, Archive.Entry entry) {
-        super(module, path, getImageFileType(entry));
+        super(module, path, getImageFileType(Objects.requireNonNull(entry)));
         this.entry = entry;
     }
 
@@ -65,7 +64,6 @@
     }
 
     private static ModuleEntry.Type getImageFileType(Archive.Entry entry) {
-        Objects.requireNonNull(entry);
         switch(entry.type()) {
             case CLASS_OR_RESOURCE:
                 return ModuleEntry.Type.CLASS_OR_RESOURCE;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java	Tue Jun 28 16:07:23 2016 -0300
@@ -28,6 +28,7 @@
 import java.nio.ByteOrder;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import jdk.internal.jimage.ImageHeader;
 import jdk.internal.jimage.ImageStream;
 import jdk.internal.jimage.ImageStringsReader;
@@ -54,7 +55,7 @@
     }
 
     public BasicImageWriter(ByteOrder byteOrder) {
-        this.byteOrder = byteOrder;
+        this.byteOrder = Objects.requireNonNull(byteOrder);
         this.input = new ArrayList<>();
         this.strings = new ImageStringsWriter();
         this.headerStream = new ImageStream(byteOrder);
@@ -96,8 +97,8 @@
     private void generatePerfectHash() {
         PerfectHashBuilder<ImageLocationWriter> builder =
             new PerfectHashBuilder<>(
-                        PerfectHashBuilder.Entry.class, // PerfectHashBuilder.Entry<ImageLocationWriter>().getClass()
-                        PerfectHashBuilder.Bucket.class); // PerfectHashBuilder.Bucket<ImageLocationWriter>().getClass()
+                        PerfectHashBuilder.Entry.class,
+                        PerfectHashBuilder.Bucket.class);
 
         input.forEach((location) -> {
             builder.put(location.getFullName(), location);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java	Tue Jun 28 16:07:23 2016 -0300
@@ -31,7 +31,6 @@
 import java.io.OutputStream;
 import java.io.UncheckedIOException;
 import java.util.Objects;
-import jdk.tools.jlink.plugin.ModuleEntry;
 
 /**
  * A ModuleEntry backed by a given byte[].
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java	Tue Jun 28 16:07:23 2016 -0300
@@ -112,13 +112,11 @@
 
     @Override
     public Stream<Entry> entries() {
-        Stream<Entry> ret = null;
         try {
-            ret = Files.walk(dirPath).map(this::toEntry).filter(n -> n != null);
+            return Files.walk(dirPath).map(this::toEntry).filter(n -> n != null);
         } catch (IOException ex) {
             throw new RuntimeException(ex);
         }
-        return ret;
     }
 
     private Archive.Entry toEntry(Path p) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java	Tue Jun 28 16:07:23 2016 -0300
@@ -25,10 +25,8 @@
 package jdk.tools.jlink.internal;
 
 import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.ByteOrder;
 import java.nio.file.Files;
@@ -47,7 +45,6 @@
 import jdk.tools.jlink.internal.ModulePoolImpl.CompressedModuleData;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.ModuleEntry;
 
 /**
@@ -73,7 +70,7 @@
     private final Map<String, List<Entry>> entriesForModule = new HashMap<>();
     private final ImagePluginStack plugins;
     private ImageFileCreator(ImagePluginStack plugins) {
-        this.plugins = plugins;
+        this.plugins = Objects.requireNonNull(plugins);
     }
 
     public static ExecutableImage create(Set<Archive> archives,
@@ -232,9 +229,9 @@
         out.write(bytes, 0, bytes.length);
 
         // write module content
-        for (ModuleEntry res : content) {
+        content.stream().forEach((res) -> {
             res.write(out);
-        }
+        });
 
         tree.addContent(out);
 
@@ -283,21 +280,6 @@
         return resources;
     }
 
-    private static final int BUF_SIZE = 8192;
-
-    private static byte[] readAllBytes(InputStream is) throws IOException {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        byte[] buf = new byte[BUF_SIZE];
-        while (true) {
-            int n = is.read(buf);
-            if (n < 0) {
-                break;
-            }
-            baos.write(buf, 0, n);
-        }
-        return baos.toByteArray();
-    }
-
     /**
      * Helper method that splits a Resource path onto 3 items: module, parent
      * and resource name.
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java	Tue Jun 28 16:07:23 2016 -0300
@@ -47,18 +47,18 @@
  */
 public final class ImagePluginConfiguration {
 
-    private static final List<Plugin.Category> CATEGORIES_ORDER = new ArrayList<>();
+    private static final List<Category> CATEGORIES_ORDER = new ArrayList<>();
 
     static {
-        CATEGORIES_ORDER.add(Plugin.Category.FILTER);
-        CATEGORIES_ORDER.add(Plugin.Category.TRANSFORMER);
-        CATEGORIES_ORDER.add(Plugin.Category.MODULEINFO_TRANSFORMER);
-        CATEGORIES_ORDER.add(Plugin.Category.SORTER);
-        CATEGORIES_ORDER.add(Plugin.Category.COMPRESSOR);
-        CATEGORIES_ORDER.add(Plugin.Category.METAINFO_ADDER);
-        CATEGORIES_ORDER.add(Plugin.Category.VERIFIER);
-        CATEGORIES_ORDER.add(Plugin.Category.PROCESSOR);
-        CATEGORIES_ORDER.add(Plugin.Category.PACKAGER);
+        CATEGORIES_ORDER.add(Category.FILTER);
+        CATEGORIES_ORDER.add(Category.TRANSFORMER);
+        CATEGORIES_ORDER.add(Category.MODULEINFO_TRANSFORMER);
+        CATEGORIES_ORDER.add(Category.SORTER);
+        CATEGORIES_ORDER.add(Category.COMPRESSOR);
+        CATEGORIES_ORDER.add(Category.METAINFO_ADDER);
+        CATEGORIES_ORDER.add(Category.VERIFIER);
+        CATEGORIES_ORDER.add(Category.PROCESSOR);
+        CATEGORIES_ORDER.add(Category.PACKAGER);
     }
 
     private ImagePluginConfiguration() {
@@ -72,8 +72,8 @@
         if (pluginsConfiguration == null) {
             return new ImagePluginStack();
         }
-        Map<Plugin.Category, List<Plugin>> plugins = new LinkedHashMap<>();
-        for (Plugin.Category cat : CATEGORIES_ORDER) {
+        Map<Category, List<Plugin>> plugins = new LinkedHashMap<>();
+        for (Category cat : CATEGORIES_ORDER) {
             plugins.put(cat, new ArrayList<>());
         }
 
@@ -96,22 +96,22 @@
 
         List<TransformerPlugin> transformerPlugins = new ArrayList<>();
         List<PostProcessorPlugin> postProcessingPlugins = new ArrayList<>();
-        for (Entry<Plugin.Category, List<Plugin>> entry : plugins.entrySet()) {
+        plugins.entrySet().stream().forEach((entry) -> {
             // Sort according to plugin constraints
             List<Plugin> orderedPlugins = PluginOrderingGraph.sort(entry.getValue());
             Category category = entry.getKey();
-            for (Plugin p : orderedPlugins) {
+            orderedPlugins.stream().forEach((p) -> {
                 if (category.isPostProcessor()) {
                     @SuppressWarnings("unchecked")
-                    PostProcessorPlugin pp = (PostProcessorPlugin) p;
+                            PostProcessorPlugin pp = (PostProcessorPlugin) p;
                     postProcessingPlugins.add(pp);
                 } else {
                     @SuppressWarnings("unchecked")
-                    TransformerPlugin trans = (TransformerPlugin) p;
+                            TransformerPlugin trans = (TransformerPlugin) p;
                     transformerPlugins.add(trans);
                 }
-            }
-        }
+            });
+        });
         Plugin lastSorter = null;
         for (Plugin plugin : transformerPlugins) {
             if (plugin.getName().equals(pluginsConfiguration.getLastSorterPluginName())) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,7 +24,6 @@
  */
 package jdk.tools.jlink.internal;
 
-import java.io.ByteArrayInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.lang.module.ModuleDescriptor;
@@ -96,7 +95,7 @@
 
         public CheckOrderResourcePool(ByteOrder order, List<ModuleEntry> orderedList, StringTable table) {
             super(order, table);
-            this.orderedList = orderedList;
+            this.orderedList = Objects.requireNonNull(orderedList);
         }
 
         /**
@@ -119,7 +118,6 @@
 
         private int currentid = 0;
         private final Map<String, Integer> stringsUsage = new HashMap<>();
-
         private final Map<String, Integer> stringsMap = new HashMap<>();
         private final Map<Integer, String> reverseMap = new HashMap<>();
 
@@ -161,12 +159,12 @@
         }
     }
 
+    private final ImageBuilder imageBuilder;
     private final Plugin lastSorter;
     private final List<TransformerPlugin> contentPlugins = new ArrayList<>();
     private final List<PostProcessorPlugin> postProcessingPlugins = new ArrayList<>();
     private final List<ResourcePrevisitor> resourcePrevisitors = new ArrayList<>();
 
-    private final ImageBuilder imageBuilder;
 
     public ImagePluginStack() {
         this(null, Collections.emptyList(), null,
@@ -177,31 +175,32 @@
             List<TransformerPlugin> contentPlugins,
             Plugin lastSorter,
             List<PostProcessorPlugin> postprocessingPlugins) {
-        Objects.requireNonNull(contentPlugins);
+        this.imageBuilder = Objects.requireNonNull(imageBuilder);
         this.lastSorter = lastSorter;
-        for (TransformerPlugin p : contentPlugins) {
+        Objects.requireNonNull(contentPlugins);
+        Objects.requireNonNull(postprocessingPlugins);
+        contentPlugins.stream().forEach((p) -> {
             Objects.requireNonNull(p);
             if (p instanceof ResourcePrevisitor) {
                 resourcePrevisitors.add((ResourcePrevisitor) p);
             }
             this.contentPlugins.add(p);
-        }
-        for (PostProcessorPlugin p : postprocessingPlugins) {
+        });
+        postprocessingPlugins.stream().forEach((p) -> {
             Objects.requireNonNull(p);
             this.postProcessingPlugins.add(p);
-        }
-        this.imageBuilder = imageBuilder;
+        });
     }
 
     public void operate(ImageProvider provider) throws Exception {
         ExecutableImage img = provider.retrieve(this);
         List<String> arguments = new ArrayList<>();
-        for (PostProcessorPlugin plugin : postProcessingPlugins) {
-            List<String> lst = plugin.process(img);
-            if (lst != null) {
-                arguments.addAll(lst);
-            }
-        }
+        postProcessingPlugins.stream()
+                .map((plugin) -> plugin.process(img))
+                .filter((lst) -> (lst != null))
+                .forEach((lst) -> {
+                     arguments.addAll(lst);
+                });
         img.storeLaunchArgs(arguments);
     }
 
@@ -230,15 +229,15 @@
                     resources.getStringTable());
         }
         PreVisitStrings previsit = new PreVisitStrings();
-        for (ResourcePrevisitor p : resourcePrevisitors) {
+        resourcePrevisitors.stream().forEach((p) -> {
             p.previsit(resources, previsit);
-        }
+        });
 
         // Store the strings resulting from the previsit.
         List<String> sorted = previsit.getSortedStrings();
-        for (String s : sorted) {
+        sorted.stream().forEach((s) -> {
             resources.getStringTable().addString(s);
-        }
+        });
 
         ModulePoolImpl current = resources;
         List<ModuleEntry> frozenOrder = null;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java	Tue Jun 28 16:07:23 2016 -0300
@@ -113,8 +113,7 @@
             private final boolean isEmpty;
 
             PackageReference(String name, boolean isEmpty) {
-                Objects.requireNonNull(name);
-                this.name = name;
+                this.name = Objects.requireNonNull(name);
                 this.isEmpty = isEmpty;
             }
 
@@ -132,12 +131,8 @@
 
         private void addReference(String name, boolean isEmpty) {
             PackageReference ref = references.get(name);
-            if (ref == null) {
+            if (ref == null || ref.isEmpty) {
                 references.put(name, new PackageReference(name, isEmpty));
-            } else {
-                if (ref.isEmpty) { // replace with new one incase non empty.
-                    references.put(name, new PackageReference(name, isEmpty));
-                }
             }
         }
 
@@ -267,8 +262,7 @@
             }
             // Validate that the packages are well formed.
             for (Node n : packages.children.values()) {
-                PackageNode pkg = (PackageNode) n;
-                pkg.validate();
+                ((PackageNode)n).validate();
             }
 
         }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java	Tue Jun 28 16:07:23 2016 -0300
@@ -44,9 +44,15 @@
 
         // Reserve 0 offset for empty string.
         int offset = addString("");
-        assert offset == 0 : "Empty string not zero offset";
+        if (offset != 0) {
+            throw new InternalError("Empty string not offset zero");
+        }
+
         // Reserve 1 offset for frequently used ".class".
-        addString("class");
+        offset = addString("class");
+        if (offset != 1) {
+            throw new InternalError("'class' string not offset one");
+        }
     }
 
     private int addString(final String string) {
@@ -76,7 +82,9 @@
     public String get(int offset) {
         ByteBuffer buffer = stream.getBuffer();
         int capacity = buffer.capacity();
-        assert 0 <= offset && offset < capacity : "String buffer offset out of range";
+        if (offset < 0 || offset >= capacity) {
+            throw new InternalError("String buffer offset out of range");
+        }
         int zero = NOT_FOUND;
         for (int i = offset; i < capacity; i++) {
             if (buffer.get(i) == '\0') {
@@ -84,7 +92,9 @@
                 break;
             }
         }
-        assert zero != NOT_FOUND;
+        if (zero == NOT_FOUND) {
+            throw new InternalError("String zero terminator not found");
+        }
         int length = zero - offset;
         byte[] bytes = new byte[length];
         int mark = buffer.position();
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java	Tue Jun 28 16:07:23 2016 -0300
@@ -30,8 +30,6 @@
 import java.io.UncheckedIOException;
 import java.nio.file.Path;
 import java.util.Objects;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
@@ -53,8 +51,8 @@
 
         JarEntry(String path, String name, EntryType type, ZipFile file, ZipEntry entry) {
             super(JarArchive.this, path, name, type);
-            this.entry = entry;
-            this.file = file;
+            this.entry = Objects.requireNonNull(entry);
+            this.file = Objects.requireNonNull(file);
             size = entry.getSize();
         }
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Tue Jun 28 16:07:23 2016 -0300
@@ -82,7 +82,7 @@
     private static final TaskHelper taskHelper
             = new TaskHelper(JLINK_BUNDLE);
 
-    static Option<?>[] recognizedOptions = {
+    private static final Option<?>[] recognizedOptions = {
         new Option<JlinkTask>(false, (task, opt, arg) -> {
             task.options.help = true;
         }, "--help"),
@@ -325,7 +325,6 @@
                                                Set<String> limitMods,
                                                Set<String> addMods)
     {
-
         ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[0]));
 
         // jmods are located at link-time
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java	Tue Jun 28 16:07:23 2016 -0300
@@ -25,7 +25,6 @@
 
 package jdk.tools.jlink.internal;
 
-import jdk.tools.jlink.internal.JarArchive;
 import java.nio.file.Path;
 import java.util.Objects;
 import jdk.tools.jlink.internal.Archive.Entry.EntryType;
@@ -35,7 +34,7 @@
  */
 public class JmodArchive extends JarArchive {
 
-    private static final String JMOD_EXT = ".jmod";
+    private static final String JMOD_EXT    = ".jmod";
     private static final String MODULE_NAME = "module";
     private static final String MODULE_INFO = "module-info.class";
     private static final String CLASSES     = "classes";
@@ -46,8 +45,9 @@
     public JmodArchive(String mn, Path jmod) {
         super(mn, jmod);
         String filename = Objects.requireNonNull(jmod.getFileName()).toString();
-        if (!filename.endsWith(JMOD_EXT))
+        if (!filename.endsWith(JMOD_EXT)) {
             throw new UnsupportedOperationException("Unsupported format: " + filename);
+        }
     }
 
     @Override
@@ -65,7 +65,6 @@
             case MODULE_NAME:
                 return EntryType.MODULE_NAME;
             default:
-                //throw new InternalError("unexpected entry: " + name + " " + zipfile.toString()); //TODO
                 throw new InternalError("unexpected entry: " + section);
         }
     }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java	Tue Jun 28 16:07:23 2016 -0300
@@ -39,8 +39,9 @@
     public ModularJarArchive(String mn, Path jmod) {
         super(mn, jmod);
         String filename = Objects.requireNonNull(jmod.getFileName()).toString();
-        if (!filename.endsWith(JAR_EXT))
+        if (!filename.endsWith(JAR_EXT)) {
             throw new UnsupportedOperationException("Unsupported format: " + filename);
+        }
     }
 
     @Override
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,7 +24,6 @@
  */
 package jdk.tools.jlink.internal;
 
-import java.io.InputStream;
 import java.nio.file.Path;
 import java.util.Objects;
 import jdk.tools.jlink.plugin.ModuleEntry;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,8 +24,6 @@
  */
 package jdk.tools.jlink.internal;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
 import java.lang.module.ModuleDescriptor;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
@@ -168,8 +166,8 @@
     }
 
     public ModulePoolImpl(ByteOrder order, StringTable table) {
-        this.order = order;
-        this.table = table;
+        this.order = Objects.requireNonNull(order);
+        this.table = Objects.requireNonNull(table);
     }
 
     /**
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java	Tue Jun 28 16:07:23 2016 -0300
@@ -31,7 +31,6 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Objects;
-import jdk.tools.jlink.plugin.ModuleEntry;
 
 /**
  * A ModuleEntry backed by a given nio Path.
@@ -43,9 +42,9 @@
      * Create a new PathModuleEntry.
      *
      * @param module The module name.
-     * @param file The data file identifier.
+     * @param path The path for the resource content.
      * @param type The data type.
-     * @param file The Path for the resource content.
+     * @param file The data file identifier.
      */
     public PathModuleEntry(String module, String path, Type type, Path file) {
         super(module, path, type);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java	Tue Jun 28 16:07:23 2016 -0300
@@ -42,7 +42,6 @@
      * @param resources Read only resources.
      * @param strings StringTable instance. Add string to the StringTable to track string
      * usage.
-     * @throws PluginException
      */
     public void previsit(ModulePool resources, StringTable strings);
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java	Tue Jun 28 16:07:23 2016 -0300
@@ -34,7 +34,6 @@
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.List;
-import java.util.Objects;
 import java.util.stream.Collectors;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.plugin.Plugin.Category;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java	Tue Jun 28 16:07:23 2016 -0300
@@ -127,7 +127,7 @@
         jlink.build(jlinkConfig, pluginConfig);
     }
 
-    /**
+    /*
      * Returns a ModuleFinder that limits observability to the given root
      * modules, their transitive dependences, plus a set of other modules.
      */
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,7 +24,6 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.util.Collections;
 import java.util.Map;
 
 import jdk.tools.jlink.internal.ModulePoolImpl;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,14 +24,11 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.io.UncheckedIOException;
-import java.util.Collections;
 import java.util.Map;
 import java.util.function.Predicate;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.ModuleEntry;
-import jdk.tools.jlink.internal.Utils;
 
 /**
  *
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,7 +24,6 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.util.Collections;
 import java.util.Map;
 import java.util.function.Predicate;
 import jdk.tools.jlink.plugin.TransformerPlugin;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -25,12 +25,10 @@
 package jdk.tools.jlink.internal.plugins;
 
 import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.UncheckedIOException;
 import java.nio.charset.StandardCharsets;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -26,7 +26,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.UncheckedIOException;
 import java.nio.file.FileVisitResult;
 import java.nio.file.FileVisitor;
@@ -35,7 +34,6 @@
 import java.nio.file.Paths;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,10 +24,8 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.io.ByteArrayInputStream;
 import java.lang.reflect.Method;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,10 +24,8 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.io.ByteArrayInputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.IllformedLocaleException;
 import java.util.Locale;
 import java.util.List;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -30,7 +30,6 @@
 import java.io.UncheckedIOException;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -30,11 +30,9 @@
 import java.nio.file.Files;
 import java.nio.file.PathMatcher;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.function.ToIntFunction;
 import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.plugin.ModuleEntry;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -26,7 +26,6 @@
 
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -46,7 +46,6 @@
 import java.io.InputStream;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,9 +24,6 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.io.ByteArrayInputStream;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.function.Predicate;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassWriter;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -24,7 +24,6 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.util.Collections;
 import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java	Tue Jun 28 16:07:23 2016 -0300
@@ -28,7 +28,6 @@
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.Map;
 import java.util.function.Predicate;
 import java.util.zip.Deflater;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java	Mon Jun 27 11:52:49 2016 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java	Tue Jun 28 16:07:23 2016 -0300
@@ -76,9 +76,7 @@
 
         @Override
         public int hashCode() {
-            int hash = 3;
-            hash = 79 * hash + Objects.hashCode(this.firstInstruction);
-            return hash;
+            return Objects.hashCode(this.firstInstruction);
         }
 
         @Override
@@ -214,9 +212,7 @@
 
         @Override
         public int hashCode() {
-            int hash = 3;
-            hash = 89 * hash + this.getIndex();
-            return hash;
+            return this.getIndex();
         }
 
         @Override