mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-07 22:50:49 +00:00
8160459: jlink minor code clean up
Reviewed-by: mchung
This commit is contained in:
parent
78f385b79a
commit
ef2abc8eff
@ -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 @@ abstract class AbstractModuleEntry implements ModuleEntry {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 89 * hash + Objects.hashCode(this.path);
|
||||
return hash;
|
||||
return Objects.hashCode(this.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -42,7 +42,6 @@ public interface Archive {
|
||||
public abstract class Entry {
|
||||
|
||||
public static enum EntryType {
|
||||
|
||||
MODULE_NAME,
|
||||
CLASS_OR_RESOURCE,
|
||||
NATIVE_LIB,
|
||||
@ -57,14 +56,10 @@ public interface Archive {
|
||||
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 @@ public interface Archive {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns the name of this entry.
|
||||
*/
|
||||
public String name() {
|
||||
@ -91,7 +86,7 @@ public interface Archive {
|
||||
return "type " + type.name() + " path " + path;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns the number of uncompressed bytes for this entry.
|
||||
*/
|
||||
public abstract long size();
|
||||
@ -99,17 +94,17 @@ public interface Archive {
|
||||
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 @@ public interface Archive {
|
||||
*/
|
||||
Stream<Entry> entries();
|
||||
|
||||
/**
|
||||
/*
|
||||
* Open the archive
|
||||
*/
|
||||
void open() throws IOException;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Close the archive
|
||||
*/
|
||||
void close() throws IOException;
|
||||
|
||||
@ -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 @@ final class ArchiveEntryModuleEntry extends AbstractModuleEntry {
|
||||
* @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 @@ final class ArchiveEntryModuleEntry extends AbstractModuleEntry {
|
||||
}
|
||||
|
||||
private static ModuleEntry.Type getImageFileType(Archive.Entry entry) {
|
||||
Objects.requireNonNull(entry);
|
||||
switch(entry.type()) {
|
||||
case CLASS_OR_RESOURCE:
|
||||
return ModuleEntry.Type.CLASS_OR_RESOURCE;
|
||||
|
||||
@ -28,6 +28,7 @@ package jdk.tools.jlink.internal;
|
||||
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 final class BasicImageWriter {
|
||||
}
|
||||
|
||||
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 @@ public final class BasicImageWriter {
|
||||
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);
|
||||
|
||||
@ -31,7 +31,6 @@ import java.io.InputStream;
|
||||
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[].
|
||||
|
||||
@ -112,13 +112,11 @@ public class DirArchive implements Archive {
|
||||
|
||||
@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) {
|
||||
|
||||
@ -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.Archive.Entry.EntryType;
|
||||
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 @@ public final class ImageFileCreator {
|
||||
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 @@ public final class ImageFileCreator {
|
||||
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 @@ public final class ImageFileCreator {
|
||||
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.
|
||||
|
||||
@ -47,18 +47,18 @@ import jdk.tools.jlink.plugin.TransformerPlugin;
|
||||
*/
|
||||
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 @@ public final class ImagePluginConfiguration {
|
||||
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 @@ public final class ImagePluginConfiguration {
|
||||
|
||||
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())) {
|
||||
|
||||
@ -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 final class ImagePluginStack {
|
||||
|
||||
public CheckOrderResourcePool(ByteOrder order, List<ModuleEntry> orderedList, StringTable table) {
|
||||
super(order, table);
|
||||
this.orderedList = orderedList;
|
||||
this.orderedList = Objects.requireNonNull(orderedList);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,7 +118,6 @@ public final class ImagePluginStack {
|
||||
|
||||
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 @@ public final class ImagePluginStack {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ public final class ImagePluginStack {
|
||||
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 @@ public final class ImagePluginStack {
|
||||
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;
|
||||
|
||||
@ -113,8 +113,7 @@ public final class ImageResourcesTree {
|
||||
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 @@ public final class ImageResourcesTree {
|
||||
|
||||
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 @@ public final class ImageResourcesTree {
|
||||
}
|
||||
// Validate that the packages are well formed.
|
||||
for (Node n : packages.children.values()) {
|
||||
PackageNode pkg = (PackageNode) n;
|
||||
pkg.validate();
|
||||
((PackageNode)n).validate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -44,9 +44,15 @@ class ImageStringsWriter implements ImageStrings {
|
||||
|
||||
// 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 @@ class ImageStringsWriter implements ImageStrings {
|
||||
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 @@ class ImageStringsWriter implements ImageStrings {
|
||||
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();
|
||||
|
||||
@ -30,8 +30,6 @@ import java.io.InputStream;
|
||||
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 @@ public abstract class JarArchive implements Archive {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ public class JlinkTask {
|
||||
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 @@ public class JlinkTask {
|
||||
Set<String> limitMods,
|
||||
Set<String> addMods)
|
||||
{
|
||||
|
||||
ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[0]));
|
||||
|
||||
// jmods are located at link-time
|
||||
|
||||
@ -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 @@ import jdk.tools.jlink.internal.Archive.Entry.EntryType;
|
||||
*/
|
||||
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 class JmodArchive extends JarArchive {
|
||||
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 @@ public class JmodArchive extends JarArchive {
|
||||
case MODULE_NAME:
|
||||
return EntryType.MODULE_NAME;
|
||||
default:
|
||||
//throw new InternalError("unexpected entry: " + name + " " + zipfile.toString()); //TODO
|
||||
throw new InternalError("unexpected entry: " + section);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,8 +39,9 @@ public class ModularJarArchive extends JarArchive {
|
||||
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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 class ModulePoolImpl implements ModulePool {
|
||||
}
|
||||
|
||||
public ModulePoolImpl(ByteOrder order, StringTable table) {
|
||||
this.order = order;
|
||||
this.table = table;
|
||||
this.order = Objects.requireNonNull(order);
|
||||
this.table = Objects.requireNonNull(table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -31,7 +31,6 @@ import java.io.UncheckedIOException;
|
||||
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 @@ public class PathModuleEntry extends AbstractModuleEntry {
|
||||
* 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);
|
||||
|
||||
@ -42,7 +42,6 @@ public interface ResourcePrevisitor {
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ import java.util.ArrayList;
|
||||
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;
|
||||
|
||||
@ -127,7 +127,7 @@ public final class AppRuntimeImageBuilder {
|
||||
jlink.build(jlinkConfig, pluginConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns a ModuleFinder that limits observability to the given root
|
||||
* modules, their transitive dependences, plus a set of other modules.
|
||||
*/
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
*/
|
||||
package jdk.tools.jlink.internal.plugins;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.tools.jlink.internal.ModulePoolImpl;
|
||||
|
||||
@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -26,7 +26,6 @@ package jdk.tools.jlink.internal.plugins;
|
||||
|
||||
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.Path;
|
||||
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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -30,7 +30,6 @@ import java.io.OutputStream;
|
||||
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;
|
||||
|
||||
@ -30,11 +30,9 @@ import java.nio.file.FileSystem;
|
||||
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;
|
||||
|
||||
@ -26,7 +26,6 @@ package jdk.tools.jlink.internal.plugins;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -46,7 +46,6 @@ import java.io.IOException;
|
||||
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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -28,7 +28,6 @@ import java.io.ByteArrayOutputStream;
|
||||
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;
|
||||
|
||||
@ -76,9 +76,7 @@ public final class ControlFlow {
|
||||
|
||||
@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 @@ public final class ControlFlow {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 89 * hash + this.getIndex();
|
||||
return hash;
|
||||
return this.getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user